me1000 Posted September 30, 2007 Share Posted September 30, 2007 Is anyone familiar with jQuery? I have a div called testidrop, <div class="testidrop" id="testidrop">...</div> normally is is hidden, but when I click on a link (testialink) it should drop down, <a href="#" id="testialink" class="testialink">Testimonials</a> So I thought it was all working great, until I discovered than whenever you click ANYWHERE on the page it drops down! Here is the code in the head tag <script> //show testimonials $(document.getElementById('testialink')).click(function(){$(document.getElementById('testidrop')).slideToggle("slow")}); $(document.getElementById('close')).click(function(){$(document.getElementById('testidrop')).slideup("slow")}); </script> (BTW the reason for the close one, us because there is a link within the testidrop div that will close it) any idea why this happens? or what I can do to fix it? Big Thanks, Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 30, 2007 Share Posted September 30, 2007 i dont use jQuery, but the $() function is usually a replacement for document.getElementById. you maybe when you do $(document) it does the whole page. just try $('testialink') Quote Link to comment Share on other sites More sharing options...
me1000 Posted October 1, 2007 Author Share Posted October 1, 2007 Thank you for your reply, $('testialink').click(function(){$(document.getElementById('testidrop')).slideToggle("slow")}); Is that what you mean? That didn't work... Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted October 1, 2007 Share Posted October 1, 2007 you only did that half way try the other document.getElementById() too $('testialink').click(function(){$(document.getElementById('testidrop')).slideToggle("slow")}); the red part is just nonsense change the whole code to $('testialink').click(function(){$('testidrop').slideToggle("slow")}); not sure if that works with a click function that way then again i am not familiar with jquery but it looks similar to prototype and mootools Quote Link to comment Share on other sites More sharing options...
me1000 Posted October 1, 2007 Author Share Posted October 1, 2007 This is what i finally got to work, $(document).ready(setTestimonials); function setTestimonials() { $('#testialink').click( function(){ $('#testidrop').slideToggle('slow') } ); $('#close').click( function(){ $('#testidrop').slideUp('slow') } ); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.