What is the proper syntax for toggling the this.id object
$(this).attr("id").toggle("");
Thanks. Google is surprisingly not helping :(
What is the proper syntax for toggling the this.id object
$(this).attr("id").toggle("");
Thanks. Google is surprisingly not helping :(
toggle() is only used for showing/hiding an element, so your question is not entirely clear.
If you want to remove the id, you could use:
$(this).attr("id","");
Or maybe you want to toggle an element with a specific id:
$("#myid").toggle();
The reason it is not working is that your first
$(this).attr("id")
Returns a string, the ID of your item. What you probably want is:
$(this).toggle();
This will look for DIVs with any ID attribute and toggle on click:
$('div[id]').click(function() {
$(this).toggle();
}