hide - jquery, how to find the parent div id? -



hide - jquery, how to find the parent div id? -

im trying hide parent div contains clicked link:

<div class="user" id="request_1"> <div class="information"> <ul> <li><a href="javascript:void(0)" class="approve_friends agree">agree1</a></li> </ul> </div> </div> <div class="user" id="request_2"> <div class="information"> <ul> <li><a href="javascript:void(0)" class="approve_friends agree">agree3</a></li> </ul> </div> </div> <div class="user" id="request_3"> <div class="information"> <ul> <li><a href="javascript:void(0)" class="approve_friends agree">agree4</a></li> </ul> </div> </div> $('.agree').live("click", function(){ var currentid2 = $(this).parent("div:second").attr('id'); alert (currentid2); $('#'.currentid).hide('slow'); });

so when click on agree1, want hide corespondent div id request_1

here jsfiddle.

any ideas doing wrong?

thanks

i used parents instead of parent, , line hide element needed + sign, not dot.

$('.agree').live("click", function(){ var currentid2 = $(this).parents(".user").attr('id'); alert (currentid2); $('#' + currentid2).hide('slow'); });

http://jsfiddle.net/ythmh/1/

jquery hide parent

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -