<my-tag data-custom-attribute="value"></my-tag>
<script>
var myTag = document.querySelector("my-tag")
var customAttributeValue = myTag.dataset.customAttribute
console.log(customAttributeValue)// Output: "value"
</script>
可以这样:<span bb="123" onclick="aa(this.bb)">125</span>
js代码:
function aa(val){
alert(val) //就会输出 123
//在这里val 就是你所点击的span的bb值
}