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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    9
    Thanked 0 Times in 0 Posts

    How to apply a jQuery selector to a form or button?

    The link “small Window ” opens the test page in a small window, how do I do the same thing with the “small Window” button?
    You can see a working example of this page at
    http://fozz.dyndns-ip.com/testingser...w/greybox.html

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>fozz</title>
    <link href="greybox/greybox2.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="greybox/jquery.greybox2.js"></script>
    <!-- start Greybox -->
    <script type="text/javascript">
    $(document).ready(function() {
      var gbOptions = {
        gbWidth: 700,
        gbHeight: 550
      };
    	$('.smallWindow div').greybox(gbOptions);//this has no effect
    	$('.smallWindow a').greybox(gbOptions);
    }); 
    </script>
    <!-- end Graybox -->
    </head>
    <body>
      <ul>
        <li><a href="testPage.php">large Window</a></li>
        <li class="smallWindow"><a href="testPage.php">small Window</a></li>
      </ul>
    <div class="smallWindow">
    <form action="testPage.php" method="get" name="mybutton">
      <input name="mybutton" type="submit" value="test page">
    </form>
    </div>
    
    </body>
    </html>

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Code:
    $("input[name=mybutton]").click(function(){
    //do something
    })

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    New England
    Posts
    62
    Thanks
    0
    Thanked 10 Times in 10 Posts
    From the looks of it, this greybox thing is automatically sets an event listener to certain objects, like an <a> when you perform .greybox() on it. I tried adding the same .greybox(gbOptions) to the button, but it had no affect.

    It seems like you either are going to read the documentation of greybox to see if it supports buttons, or dig into the jquery.greybox2.js and try to fix it yourself.

  • Users who have thanked mvmacd for this post:

    chrisfozz (11-23-2011)

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    9
    Thanked 0 Times in 0 Posts
    re the above code snipit, i've either put this in th wrong place or there is some other problem; it still does not work.
    I've decided to leave this one for the time being and have addopted a different approach to the page.
    Many thanks for taking the time to look at this.
    Regards
    Chris


  •  

    Posting Permissions

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