单击()有效,悬停()无效
click() works, hover() not
我的 hover()
不工作。当我执行 click()
时,它仍然有效:
$( "#testcard" ).on( "hover", 'tbody #thei',
function() {
console.log("in");
}, function(){
console.log("out");
});
这对我有用,所以 tomc 的回答对我来说很好。
我不相信有 .on('hover'),它只是 .hover
$('tbody #thei').hover(
function() {
console.log("in");
}, function() {
console.log("out");
}
);
http://jsfiddle.net/xk34xf8g/1/
如果您使用的是动态元素,则应改用 on.('mouseenter') 和 .on('mouseleave')。
$("#testcard")
.on("mouseenter", "tbody #thei", function(event){
console.log("in");
})
.on("mouseleave", "tbody #thei", function(event){
console.log("out");
});
$("p").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "pink");
});
使用上面的代码就可以解决问题。有关此内容的更多信息,请访问此 link。
Click Here...
我的 hover()
不工作。当我执行 click()
时,它仍然有效:
$( "#testcard" ).on( "hover", 'tbody #thei',
function() {
console.log("in");
}, function(){
console.log("out");
});
这对我有用,所以 tomc 的回答对我来说很好。
我不相信有 .on('hover'),它只是 .hover
$('tbody #thei').hover(
function() {
console.log("in");
}, function() {
console.log("out");
}
);
http://jsfiddle.net/xk34xf8g/1/
如果您使用的是动态元素,则应改用 on.('mouseenter') 和 .on('mouseleave')。
$("#testcard")
.on("mouseenter", "tbody #thei", function(event){
console.log("in");
})
.on("mouseleave", "tbody #thei", function(event){
console.log("out");
});
$("p").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "pink");
});
使用上面的代码就可以解决问题。有关此内容的更多信息,请访问此 link。 Click Here...