当有人单击从本网站主页上的一张幻灯片移动到另一张幻灯片的箭头(当您将鼠标悬停在 float 框上时会出现该箭头)时,我正在尝试注册:http://questtours-dc.com但由于某种原因,箭头是一个黑洞。
我目前设置了多个功能来记录点击次数,试图解决这个问题。这是一个 WordPress 网站,所以我必须传递 $。
jQuery(document).ready(function($) {
$(document).click(function(){
console.log(' A click has occurred ');
});
$(".et-arrow-next").click(function(){
console.log(' You clicked the arrow ');
});
$(".et-slider-arrows").on('click','.et-arrow-next',function(){
console.log(' 1 - You clicked the arrow ');
});
$("a.et-arrow-next").on('click',function(){
console.log(' 2 - You clicked the arrow ');
});
$('#et-slider-wrapper').on('click','.et-arrow-next', function() {
console.log(' 3 - You clicked the arrow');
});
});
当您单击页面上的任意位置( float 框两侧的两个箭头除外)时,它会记录一次单击。但每当您单击箭头时,它都不会记录任何内容。
编辑:这也不起作用。在前两个回复后添加。
$(".et-arrow-next").on("click", function() {
console.log(' You clicked the arrow ');
});
编辑2:在悬停开始后尝试定位类也不起作用
$('#et-slider-wrapper:hover .et-slider-arrows a').on('click', function() {
console.log(' 4 - You clicked the arrow ');
});
$('#et-slider-wrapper:hover .et-arrow-next').on('click', function() {
console.log(' 5 - You clicked the arrow ');
});
最佳答案
如果您尝试单击的元素是从 javascript 动态生成的,请使用
$( ".et-arrow-next" ).on( "click", function() {
console.log(' You clicked the arrow ');
});
关于javascript - jQuery .click() 不会在特定元素上触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20379168/