jquery我的要求是,当复选框被选中,并且当我将鼠标悬停在图像上时,我将图像和复选框放在page.Now上。
当复选框被选中并且鼠标悬停在图像上时,jquery不应该运行...
我的代码是这样的。
$(document).ready(
function()
{
$("#box img").click(
function()
{
var sr=$(this).attr("src");
//alert(sr);
$("#box2 img").fadeOut("slow",function(){
$("#box2").html("<img src='"+sr+"' style='opacity:0.30'/>");
$("#box2 img").fadeTo("slow",1);
});
}
);
$("#box img").hover(
function()
{
$(this).css({'z-index' : '10','border':'4px solid white'});
$(this).animate({
marginTop: '-110px',
marginLeft: '-110px',
top: '50%',
left: '50%',
width: '200px',
height: '200px'
},200);
},现在,我只需要在选中复选框时运行此函数...
发布于 2012-02-24 14:41:50
我猜您只想在特定情况下执行一些javascript代码(使用jquery),对吧?
因此,假设您有id="check"复选框和id="pix"图像
您必须将以下内容放入您的文档就绪部分:
$('#pix').mouseover(function(){
if($('#check').is(':checked')){
//your code is here or function call
}
});发布于 2012-02-24 14:44:01
我想你想要的是:
$('#image').hover(function () {
if ($('#checkbox').is(':checked')) {
//Your code to do what ever you want on entry
}
}, function () {
if ($('#checkbox').is(':checked')) {
//Your code to do what ever you want on exit
}
});发布于 2012-02-24 14:39:40
$('#image_1').mouseover(function() {
if ($('#checkbox_1').is(':checked').length == 1)
{
// do stuff
}
});https://stackoverflow.com/questions/9426428
复制相似问题