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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Location
    FL
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy jquery confusion

    Trying to have an image that appears if you click one button and disappear when you click the other button....sounds easy enough but it's not cooperating...Any help would be greatly appreciated!

    [CODE]
    <html>
    <head>
    <title>Asst3b</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
    function showPic() {
    $('img[Pic]').show(1000);
    }
    function hidePic() {
    $('img[Pic]').hide(1000);
    }
    </script>
    </head>

    <body>
    <p id="Pic" src="pic1.jpg" alt="image1"></p>
    <input type="button" value="Show Image" onclick="showPic()" />
    <input type="button" value="Hide Image" onclick="hidePic()" />
    </body>
    </html>
    [CODE]

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    An image is <img> in HTML and not <p>

    The jQuery selector should be #Pic instead of img[Pic]

  • Users who have thanked devnull69 for this post:

    seedmaniac (06-05-2011)

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Location
    FL
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thank you! alls working good now


  •  

    Tags for this Thread

    Posting Permissions

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