更新时间:2023-10-06 20:57:52
Dashboard Widgets只是运行在WebKit技术上, for Safari也应该在Dashcode中有效。以下任一应该工作:
Dashboard Widgets just run on WebKit technologies, so code valid for Safari should also be valid in Dashcode. Either of the following should work:
checkbox.checked = true;
checkbox.setAttribute("checked", "true");
它们不工作的事实表明在代码的其他地方有一个问题。我会检查行
The fact that they are not working indicates there is a problem elsewhere in your code. I would check the line
var checkbox = document.getElementById("checkbox");
正确地为复选框分配一个元素
。此外,检查您的checkbox元素的id是否有效且正确(不是重复,没有拼写错误等)。
Correctly assigns an element to the checkbox
variable. Also, check the id of your "checkbox" element is valid and correct (not a duplicate, doesn't have a typo, etc).