JS:使用JQuery通过属性选择器触发方法
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/933
JS:使用JQuery通过属性选择器触发方法
HTML部分:
<button data-action="click-me">点击我</button>
JavaScript部分:
$("[data-action='click-me']").click(function() {
alert("Hello World!");
});
This article was last edited at 2023-05-10 06:39:08