<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>ajax file</title> ???<script src="./js/jquery-1.12.4.min.js"></script> ???<script> ???????$(function(){ ???????????// 获取data-a的属性值 data("-后面的字符") ???????????alert($(".box").data("a")) ???????}); ???</script></head><body> ???<div class="box" data-a="嘿嘿"> ???????嘿嘿 ???</div> ???</body></html>
html中设置data-*属性值 并在js中进行获取属性值
原文地址:https://www.cnblogs.com/lowmanisbusy/p/9048836.html