Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Jquery复选框在悬停时选中和取消选中_C#_Jquery_Html_Asp.net_Checkbox - Fatal编程技术网

C# Jquery复选框在悬停时选中和取消选中

C# Jquery复选框在悬停时选中和取消选中,c#,jquery,html,asp.net,checkbox,C#,Jquery,Html,Asp.net,Checkbox,我使用C代码动态创建复选框并将它们添加到占位符中,我使用Jquery在鼠标悬停事件中选中/取消选中它们 C#: (j=d;j

我使用C代码动态创建复选框并将它们添加到占位符中,我使用Jquery在鼠标悬停事件中选中/取消选中它们

C#:

(j=d;j{ plhdr_seat.Controls.Add(新的LiteralControl(“”); //复选框fg=新复选框(); plhdr_seat.Controls.Add(新的LiteralControl(“”); HtmlInputCheckBox cb=新的HtmlInputCheckBox(); cb.Attributes.Add(“类”、“mew”); cb.Checked=true;//或cb.Checked=false; cb.ID=“检查”+j.ToString(); plhdr_座椅控制添加(cb); plhdr_seat.Controls.Add(新的LiteralControl(“”); } jquery:

<script>
    $(document).ready(function () {
        $(".mew").mouseover(function () {                
            var attr = $(this).attr("Checked");                               
            if (typeof attr !== typeof undefined && attr !== false)
            {
                $(this).prop('checked', false); // will check the checkbox with id check1                   
            }
            else {
                $(this).prop('checked', true); // will uncheck the checkbox with id check1                  
            }
        });
    });
</script>

$(文档).ready(函数(){
$(“.mew”).mouseover(函数(){
var attr=$(this.attr(“选中”);
if(typeof attr!==typeof undefined&&attr!==false)
{
$(this.prop('checked',false);//将选中id为check1的复选框
}
否则{
$(this.prop('checked',true);//将取消选中id为check1的复选框
}
});
});
我有这个。

悬停时,复选框未选中。但我再次在它们上面徘徊,它们没有被检查。
我无法确定问题所在。请帮帮我。

您可以使用以下方法将其简化为:

$(“.mew”).hover(函数(){
$(this.prop(“选中”),!$(this.prop(“选中”);
});

$(.mew”).on(“鼠标悬停”,函数(){
this.checked=!this.checked;
});

尝试在

例如,if
div是否保留了所有的
复选框

试试这个

$("#fixed_static").on("mouseover",".mew",function(){


});
或者你可以使用

$("html").on("mouseover",".mew",function(){


    });
试试这个

$(document).on("mouseover",".mew",function(){
    this.checked = !this.checked;// check if uncheck, uncheck if checked
    //$(this).prop('checked',!this.checked); in jquery
});

这段代码在stackoverflows的编译器中运行良好。但不是在我的visual studio中
$(document).on("mouseover",".mew",function(){
    this.checked = !this.checked;// check if uncheck, uncheck if checked
    //$(this).prop('checked',!this.checked); in jquery
});