JQuery: How to make $ (this) selector?
1 answer
Pass the function to your method html
and return the desired text you want:
$('.parent').find(".child1").html(function () {
return $(this).parent().find('.info').html();
});
From the official jQuery documentation :
.html( function )
: a function that returns the HTML content to install. Gets the index position of the element in the set and the old HTML value as arguments. jQuery frees the element before calling the function; use the oldhtml argument to link to previous content. Within a function, refers to the current item in the set.this
+5
source to share