扫码关注官方订阅号
认证高级PHP讲师
绑定事件的时候把this传进去,onclick="choose(this)"
function choose(x){
alert(x.getAttribute("data-name"))
}
$(this).attr('data-name');
获取属性 - attr()jQuery attr() 方法用于获取属性值。
$('#toy').attr('data-name');
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
绑定事件的时候把this传进去,onclick="choose(this)"
function choose(x){
}
$(this).attr('data-name');
获取属性 - attr()
jQuery attr() 方法用于获取属性值。
$('#toy').attr('data-name');