how to get the data from custom data tag in jquery
This question already has an answer here:
你可以简单地使用jquery .attr
来获得所需的输出。
console.log($("#val").attr('data-tabval'))
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#angular_code" role="tab" id="angular_code-tab" data-toggle="tab" aria-controls="angular_code">
<span id="val" data-tabval="test123" class="text">test here</span>
</a>
以下是您的要求的代码片段:
var value = $("#val").attr("data-tabval");
you can Gate custom Attribute value this code example:
$("a").click(function(event) {
alert($(this).attr("aria-controls"));
alert($(this).attr(" data-toggle"));
});
And others attribute or custom attribute
链接地址: http://www.djcxy.com/p/3926.html上一篇: 框架和库之间有什么区别?