attributes["wv"].nodeValue

w

获取自定义属性的值

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class=" item-link card-content-inner" id="gname2" wv="w2">w2
</div>


<script type="text/javascript">
    wi = 2
    $$("gname" + wi).attributes["wv"].nodeValue

    console.log($$("gname" + wi).attributes["wv"].nodeValue)
    console.log($$("gname" + wi).attributes["wv"])

    console.log($$("gname" + wi))


    function $$(id) {
        return typeof id === 'string' ? document.getElementById(id) : id;
    }

</script>


</body>
</html>
</body>
</html>
原文地址:https://www.cnblogs.com/rsapaper/p/6502578.html