Reputation: 435
What I'm trying to do is a drop down menu, and the user click on of the items inside the menu automatically closes the menu, now if working but because I'm using the
This is function that works
$("li").click(function(event)
{
$(this).closest("div").hide("slow");
});
but this one doesn't
$("hideM").click(function(event)
{
$(this).closest("div").hide("slow");
});
Upvotes: 0
Views: 176
Reputation: 2094
Change this
$("hideM").click(function(event)
{
$(this).closest("div").hide("slow");
});
To
$("#hideM").click(function(event){
$(this).closest("div").hide("slow");
});
If you are using id
as your jquery
selector , you need to prefix #
.
Upvotes: 2
Reputation: 125
You're missing '#'. Currently you are trying to use a HTML element 'hideM', which doesn't exist. To use your element with ID 'hideM', you have to use
$("#hideM").click(function(event) {
$(this).closest("div").hide("slow");
});
Upvotes: 1
Reputation: 11721
You need to add "#" as shown below...
$("#hideM").click(function(event)
{
$(this).closest("div").hide("slow");
});
Demo :- http://jsfiddle.net/5EQzs/1/
Upvotes: 1