如何获取jQuery中id属性的值?
使用jQueryattr()方法获取id属性的值。您可以尝试运行以下代码以了解如何在jQuery中获取值-
示例
<html>
<head>
<title>jQuery Example</title>
<script src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
alert($('#div1').attr('id'));
});
</script>
</head>
<body>
<div id = "div1">
<p>This is demo text.</p>
</div>
</body>
</html>