我做了一个没有的小表。复选框..当我点击"全部检查" -checkbox时,会自动检查所有复选框。这是我的代码,但我只从互联网上获取以下代码。 虽然它的工作,但我是jQuery的新手,我不明白这段代码的作用。有人可以解释一下吗?
private void Form1_Resize(object sender, EventArgs e)
{
foreach (Control control in MasterPanel.Controls)
{
control.Size = MasterPanel.Size;
}
}
答案 0 :(得分:0)
try this code..!! go thriugh this link, this will help you..
答案 1 :(得分:0)
这是带注释的脚本:
// When document is ready, run function
$(document).ready(function(){
// When 'change' event is triggered on element with id 'checkAll'
// run function
$("#checkAll").change(function () {
// Set property 'checked' of all inputs with type 'checkbox'
// to state that #checkAll input has
$("input:checkbox").prop('checked', $(this).prop("checked"));
// Alert 'Yoy have checked all'
alert("Yoy have checked all");
});
});
您可以在行动here中看到它。
如果您对 jQuery 或 JavaScript 不是很熟悉,请查看YouTube上的一些初学者教程或Google。有很多视频教程可以解释基本的 HTML 和 jQuery 这些非常有用的东西。
请注意, stackoverflow 不是其他开发人员会解释代码片段的内容的地方。
希望这很有用:)
答案 2 :(得分:0)
这很简单,首先在这个代码中简单检查第一个(全部检查)复选框然后更改事件发生了,下一行$("输入:复选框)"选择器选中全部复选框。 并且prop函数检查已检查的属性 $(本).prop("检查&#34);在复选框中添加选中的proerty,并选中所有复选框。