Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts

    jquery popup on button click

    Hi,

    I want a jquery popup to open on click on a button.

    This is the working code for a link to open a popup

    Code:
    <html>
    <head> 
    
    
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    </head> 
    
    
    <body>
    
    
    
    <a href="#popupBasic" data-rel="popup">Open Popup</a>
    
    <div data-role="popup" id="popupBasic">
    <p>This is a completely basic popup, no options set.<p>
    </div>
    
    
    </body>
    </html>
    Now, how can you get this code working inside a button onclick or something, please?



    Code:
    <button onclick="#popupBasic" data-rel="popup">Open Popup</button>

    Do you have an idea?
    Last edited by nebben; 12-14-2013 at 07:42 AM.

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,328
    Thanks
    30
    Thanked 870 Times in 868 Posts
    Use this, but you will need to move the popup down a bit:
    Code:
    <a href="#popupBasic" data-role="button" data-rel="popup">Open Popup</a>
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. Users who have thanked sunfighter for this post:

    nebben (12-16-2013)


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •