Click here to Skip to main content
15,895,142 members
Articles / Web Development / HTML

jQuery selection div html() by click something in div.

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
18 Nov 2012CPOL 0  
$('.remove').click(function () {var postHTML = $(this).closest(".post").html(); // select closest div or element with class post });try this. its working fine.

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
15 Nov 2012Jyotish Pillai
You can try this$('.remove').live('click', function() { var postHTML =$(this).parent('.post').html();});Thanks,Jyotish
Please Sign up or sign in to vote.
15 Nov 2012Lubomur 4 alternatives  
Hi, how can I select "post" div html() by click "remove".If I write $('post').html() select work only for first "post", but I need to select for example second or third.//html Some text for first div <a...
Please Sign up or sign in to vote.
16 Nov 2012Lubomur
var post = $(this).parents().parents().html();
Please Sign up or sign in to vote.
15 Nov 2012Ravi Tuvar
$('.remove').live('click', function () { $('.post:eq(1)').html(''); });Please try this this will give you the last div with class = post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer NEC HCL ST
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation (No members)


Comments and Discussions