如何使用jQuery获取元素的ID?

﹥>﹥吖頭↗ 提交于 2020-08-11 05:02:48

问题:

<div id="test"></div>
<script>
  $(document).ready(function() {
    alert($('#test').id);
  });  
</script>

Why doesn't the above work, and how should I do this? 为什么上述方法不起作用,我应该怎么做?


解决方案:

参考一: https://stackoom.com/question/Dala/如何使用jQuery获取元素的ID
参考二: https://oldbug.net/q/Dala/How-can-I-get-the-ID-of-an-element-using-jQuery
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!