![](/img/trans.png)
[英]jquery equivalent to find value of certain attribute on an html element
[英]How to write jquery to find html element id attribute value and set that value to same html class attribute?
當前嘗試編寫jQuery以查找html元素“ area”並獲取id屬性值並將該值設置為相同的html元素類屬性?
<map name="map">
<area id="test" />
.
.
.
//100 area tag
</map>
使用每個查找並遍歷所有區域標簽。 在回調內部,您可以使用$(this)
引用當前區域。
$("area").each(function() {
$(this).addClass($(this).attr("id"));
});
el = $(body).find("area");
$.each(el, function(key, element) {
element.addClass(element.attr("id"));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.