Skip to content Skip to sidebar Skip to footer

Jquery Toggle Not Working

i am trying to get jquery to hide this div and for some reason it is not working what am i doing wrong http://stat-me.com/jq.html

Solution 1:

You need to:

  1. Use document.ready
  2. Select the anchor underneath the #one div, not the div itself

So it should be:

$(document).ready(function() {
  $("#one a").click(function() {
    $("#hideme").toggle();
  });
});

Solution 2:

Your not wrapping your javascript in $(document).ready(function(){}) etc do jQuery is trying to find an element that doesn't exist yet!

Solution 3:

I am having the same situation while using ajax and applied this solution. Write javascript:void(0); instead of a '#' in href value. this prevents you to add '#' in url. use .live() when using in ajax mode. in .toggle(), pass argument as effect like 'Drop', 'slide' etc, more at http://jqueryui.com/toggle/.

$(document).ready(function(){
        $('#one a').live('click', function(){
            $('#hideme').toggle('Drop');
            returnfalse;
         });
     });

Applying return false; at last preventing me to reload the page.

Answered just for knowledge.

Post a Comment for "Jquery Toggle Not Working"