Markup:
<div class="foo">
<img src="loading.gif" class="loading" style="display: none;" />
</div>
Js:
$("div[class='foo']").click(function(e) {
e.preventDefault();
$(this).hide();
$(/* somehow select the loading img of exactly this div with class foo (not others) */).show();
});
$("div[class='foo']").click(function(e) {
e.preventDefault();
$(this).hide();
$('img.loading', this).show();
});
If you want any descendant of the given element you can use find() :
$(this).find(".foo");
If you know you only want to search for the first-level children elements, you can use children() :
$(this).children(".foo");
You could use
$(this).find("img").show();
or
$(this).find("img.loading").show();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.