Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

open modal js

$('#modal-name').modal('show');
Comment

modal show using js

 $('#ViewProfileModal').modal('show');
Comment

html modal

<div class="modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
Comment

modal javascript example

<button class="trigger">Click here to trigger the modal!</button>
<div class="modal">
    <div class="modal-content">
        <span class="close-button">&times;</span>
        <h1>Hello, I am a modal!</h1>
    </div>
</div>
Comment

javascript custom modal

Swal.fire({
  icon: 'error',
  title: 'Oops...',
  text: 'Something went wrong!',
  footer: '<a href="">Why do I have this issue?</a>'
})

this is javascript cdn put this code in your html body section ending the body section 
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
Comment

how to create modal popup in javascript

<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
  Swal.fire(
  'Good job!',
  'You clicked the button!',
  'success'
)
</script>
Comment

modal javascript

const modalGallery = (id) => {
    let modal = $('#modal-gallery-before-after');
    let popup = modal.querySelector('.popup');
    let compare__item = $(`.compare__item-${id}`);
    let popupWrap = modal.querySelector(".popup__wrap");
    let popupItems = modal.querySelector(".popup__item");
    let modal_gallery_item = $(".modal-gallery-item");
    let item__image = compare__item.querySelector('.modal-image').innerHTML;
    let item__title = compare__item.querySelector('.modal-title').innerHTML;
    let modalItem = `<div id="modal__item-${id}" class="modal__item">
    <div class="modal__image">${item__image}</div>
    <div class="modal__title">${item__title}</div>
    </div>`;
    popupItems.setAttribute('data-popup', `${id}`);
    modal_gallery_item.innerHTML = modalItem;
    popup.style.display = "block !important";
    $(`.popup__item[data-popup="${id}"]`).classList.add("show_data");
    popupWrap.classList = `popup__wrap popup__wrap--${id}`;
    setTimeout(() => {
        popup.classList.add("show_data");
    }, 10);
}

const closeModal = () => {
   let modal = $('#modal-gallery-before-after');
   let popup = modal.querySelector('.popup');
   let popupWrap = modal.querySelector(".popup__wrap");
   popup.classList.remove("show_data");
   setTimeout(() => {
    popup.style.display = "";
    popupWrap.classList = `popup__wrap`;
}, 500);
}
Comment

modal html

<div id="modal-gallery-before-after">
    <div class="popup">
        <div class="popup__overlay" onclick="closeModal()"></div>
        <div class="popup__wrap">
            <div class="popup__close" onclick="closeModal()">
            <svg style="width:16px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
                <path d="M15.4905 15.4905C15.3294 15.652 15.1379 15.7802 14.9272 15.8676C14.7165 15.955 14.4905 16 14.2624 16C14.0342 16 13.8083 15.955 13.5976 15.8676C13.3868 15.7802 13.1954 15.652 13.0342 15.4905L7.99963 10.456L2.96504 15.4905C2.63931 15.8163 2.19753 15.9993 1.73688 15.9993C1.27623 15.9993 0.834449 15.8163 0.508721 15.4905C0.182992 15.1648 0 14.723 0 14.2624C0 14.0343 0.0449253 13.8084 0.132212 13.5977C0.219498 13.387 0.347436 13.1955 0.508721 13.0342L5.54331 7.99963L0.508721 2.96504C0.182992 2.63931 0 2.19753 0 1.73688C0 1.27623 0.182992 0.834449 0.508721 0.508721C0.834449 0.182992 1.27623 0 1.73688 0C2.19753 0 2.63931 0.182992 2.96504 0.508721L7.99963 5.54331L13.0342 0.508721C13.1955 0.347436 13.387 0.219498 13.5977 0.132212C13.8084 0.0449253 14.0343 0 14.2624 0C14.4905 0 14.7163 0.0449253 14.9271 0.132212C15.1378 0.219498 15.3293 0.347436 15.4905 0.508721C15.6518 0.670005 15.7798 0.861477 15.8671 1.07221C15.9543 1.28293 15.9993 1.50879 15.9993 1.73688C15.9993 1.96497 15.9543 2.19083 15.8671 2.40156C15.7798 2.61229 15.6518 2.80376 15.4905 2.96504L10.456 7.99963L15.4905 13.0342C16.1525 13.6962 16.1525 14.8111 15.4905 15.4905Z" fill="#CF2144"/>
            </svg>
            </div>
            <div class="popup__item" data-popup ="">
                <div class="appointment__form form--style-full">
                    <div class="modal-gallery-item"></div>
                </div>
            </div>
        </div>
    </div>
</div>
 <div id="<?= get_the_ID() ?>" class="compare__item-<?= get_the_ID() ?>" data-popup="<?= get_the_ID() ?>" onClick="modalGallery(this.id)">
      <div class="modal-image">
           <?php the_post_thumbnail(); ?>
      </div>
      <div class="modal-title">
            <p><?= wp_trim_words(the_content(), 14); ?></p>
      </div>
  </div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: recaptcha v3 
Javascript :: file upload nest 
Javascript :: jquery autocomplete search 
Javascript :: file_get_contents in javascript 
Javascript :: window.open 
Javascript :: .reduce javascript 
Javascript :: change photo with js 
Javascript :: jquery parsexml get attribute 
Javascript :: how to transform object in string with scaped 
Javascript :: regex validate wallet eth 
Javascript :: angular turn text into input 
Javascript :: Javascript code to Detect All Network Number In Nigeria (MTN, Glo, Airtel & 9Mobile). 
Javascript :: access multiple classes with loop 
Javascript :: Javascript Map.prototype.size 
Javascript :: acer swift 5 
Javascript :: javascript only allow numbers 
Javascript :: react counter animation 
Javascript :: avoid compressing imagepicker react native 
Javascript :: how to push values in array 
Javascript :: node js mysql variables 
Javascript :: node mongodb $or 
Javascript :: setTimeout() Method in javascript 
Javascript :: form data to json 
Javascript :: javascript injection in mongodb 
Javascript :: node_modules/react-native-paper/lib/module/core/Provider.js 
Javascript :: javascript target closest 
Javascript :: javascript remove item from url 
Javascript :: how to add row in angular dynamically 
Javascript :: alpinejs examples stackoverflow 
Javascript :: react text docoration none 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =