如何检查具有特定属性值的元素是否存在于div标签内。如何检查具有特定属性值的html元素是否存在
例如,
<div id='testdiv'>
<a dir='hello' href='#' ></a>
</div>
<input type='button' id='btn' />
这里是我的jQuery的。
$('#btn').click(function(){
if(/*Here I need the condition to check whether, `a` tag with attribute `dir` with value `hello` is present inside `div` */)
{
alert(present);
}
}
请教亲爱的朋友,因为我是jQuery的初学者。谢谢。
合并解决这些问题:[查找与jquery的特定属性值的所有元素(http://stackoverflow.com/q/4958081)和[jQuery是否有“存在”函数?](http://stackoverflow.com/q/31044)。 –