Simple Popup with jQuery

A Popup box is used when you want to display small text, photos, maps or other content in a website. Popup is similar to dialogs. These are often generated by websites that include pop-up advertisements.  Creating Popups using jQuery is simple, which can be done using the following steps.

To create a popup, Add data-rel=”popup” and  data-role=”popup” attribute to <a>tag. Then give an id for <div>, and set the href of <a> to match the specified id.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>

<div data-role="page">
  <div data-role="header">
    <h1>Welcome to My Site</h1>
  </div>

  <div data-role="main" class="ui-content">
    <a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all">View Popup</a>

    <div data-role="popup" id="myPopup" class="ui-content">
      <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-left">Close</a>
      <p>This is a Simple PopUp Box!!!</p>
      
    </div>
  </div>

  <div data-role="footer">
    <h1>Footer</h1>
  </div>
</div>

</body>
</html>

 

Share

Morbits is One of the biggest and Proven Digital Marketing and Inbound Marketing Company from Kochi,Kerala. We undertake Web Development , Ecommerce , Mobile Apps, SEO, Server solutions , SMS,Newsletters, ORM and More since 2008

Leave a Reply

Your email address will not be published. Required fields are marked *