$(this +"selector")? $("img",this)可能吗? [英] $(this +"selector") ? $("img",this) possible?
本文介绍了$(this +"selector")? $("img",this)可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在$(this)选择器中选择"一个img.我知道我可以通过使用.find('img')
找到它,但这是可能的:
I'm trying to "select" a img inside a $(this) selector. I know I can find it by using .find('img')
but is this possible:
$("img",this)
吗?
执行此操作的最佳方法是什么?
What's the most optimal way to do this?
原始代码
<a class="picture" href="test.html">
<img src="picture.jpg" alt="awesome">
</a>
推荐答案
执行此操作的最佳方法是什么?
What's the most optimal way to do this?
$(this).find('img')
和$('img', this)
都是等效的.
从文档中
在内部,选择器上下文是通过.find()方法实现的, 因此$('span',this)等同于$(this).find('span').
Internally, selector context is implemented with the .find() method, so $('span', this) is equivalent to $(this).find('span').
这篇关于$(this +"selector")? $("img",this)可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文