Pages

Sunday 19 May 2013

jQuery Find Next Anchor Element and Hide it? how to get next anchor tag in jquery?

jQuery Find Next Anchor Element and Hide it?  
How to get next anchor tag in jquery?

<div id ="div1">
<a class='button edit' id='edit1'>Edit</a>
<a class='button Close'>Close</a>
</div>

add an edit class

$("a.edit").click(function(){
$
("a.Close").show(); //show the previously hidden element
$
(this).next("a").hide(); //hide the intended one
});
 
 
 
or 
 
 
Use the next() function in jquery
$(".edit").click(function(){ $(this).next(".close").hide();});
 
 
DEMO 

No comments:

Post a Comment