我需要捕获是否在 javascript 函数中单击了元素,但元素类已在名为“mmenu”的插件中用于显示隐藏的标题内容。该事件是否可能,或者我需要在不使用插件的情况下更改实现?
我在 HTML 中使用的元素:
<a class="custom-search-mobile" id="mobile-nav-toggle" aria-label="Toggle mobile menu"><span class="fas fa-bars"></span></a>
判断元素是否被点击的函数:
$(document).ready(function () {
$('.custom-search-mobile').on('click', function (event) {
console.log("it is clicked!!!!!!");
});
});
插件屏幕,我在其中使用我的类:
最佳答案
如果你想知道点击了哪个元素
$(document).ready(function () {
$('.custom-search-mobile').on('click', function (event) {
var el = $(this)
console.log(el);
//manipulate with element
});
});
关于javascript - 如果已在 WordPress 插件菜单中使用,我可以捕获单击元素吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52764575/