Javascript 获取新创建的html属性的值
嘿,我正在尝试创建一个新的html属性,我遵循它,我已经成功了。我还尝试在许多相同的html标记中回显属性的值,在本例中是一个Javascript 获取新创建的html属性的值,javascript,jquery,html,css,Javascript,Jquery,Html,Css,嘿,我正在尝试创建一个新的html属性,我遵循它,我已经成功了。我还尝试在许多相同的html标记中回显属性的值,在本例中是一个使用.each()循环每个节点 $("#gh").click(function() { $("#new_attr").find('.showItLink').each(function(){ alert($(this).attr("textToShow")); }); }); 如果要获取包含特定属性值的确切节点,请使用以下命令 $('.s
使用.each()
循环每个节点
$("#gh").click(function() {
$("#new_attr").find('.showItLink').each(function(){
alert($(this).attr("textToShow"));
});
});
如果要获取包含特定属性值的确切节点,请使用以下命令
$('.showItLink[textToShow="This is the text to show0"]')
您可以通过jquery中的.each()
实现场景
$("#gh").click(function() {
$("#new_attr").find('.showItLink').each(function() {
if($(this).attr("textToShow") == "This is the text to show5") {
alert ('found');
}else{
alert ('not found');
}
});
});