我无法获取 <div class="start1" id="1" point="a1">Start</div>
的值元素,我使用的代码:
$(this).click(function(){
alert($(this).attr("point"));
});
如果我输入 $(".start1")
而不是这个,然后输出值。这里有什么问题吗?
最佳答案
在此模式下尝试使用数据点而不是点和检索后:
<div class="start1" id="1" data-point="a1">Start</div>
$('.start1').click(function(){
alert($(this).data("point"));
});
关于javascript - jQuery 无法获取 attr 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18948034/