如何在具有相同id属性的所有元素上应用jquery? [英] How can i apply jquery on all elements with same id attribute?
本文介绍了如何在具有相同id属性的所有元素上应用jquery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在具有相同id属性的所有元素上应用jquery?
How can i apply jquery on all elements with same id attribute ?
我要在具有相同id的textarea
元素上应用focus()
和blur()
函数吗?
i want to apply a focus()
and blur()
function on a textarea
elements that have same id?
推荐答案
首先,具有相同ID
的元素不应超过一个.
First, you should not have more than one element with the same ID
.
但是,您可以使用CSS类来做到这一点:
However, you could do this with CSS classes:
<div>
<textarea class="Text"></textarea>
<textarea class="Text"></textarea>
<textarea class="Text"></textarea>
</div>
<script>
$(".Text").focus();
$(".Text").blur();
</script>
这篇关于如何在具有相同id属性的所有元素上应用jquery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文