And use js to execute:
]
------ --------------------------
Method 1. . .
If you need to introduce external Js, you need to refresh to execute
]
This is method two. . . .
The function to be executed by the checkbox is set in the value of the checkbox, and the parameter of the method is to pass the currently clicked checkbox as a parameter.
Here I use jquery to operate
Copy code
The code is as follows:
$ (function() {
$("ul li a").css("cursor", "pointer");
$("ul li a").click(function() {
var $ck = $(this).siblings(":checkbox");
if ($ck.attr("name") == "total")//Select all
{
if ($ ck.attr("checked") == false) {
$ck.attr("checked", "checked");
$("[name='ck']:checkbox").attr( "checked", "checked");
var ff = $ck.val();//Get the string of the function to be executed
var cc = $ck.get(0);// Convert jquery Convert the object to a DOM object
window[ff](cc);//Execute the string function and pass the current checkbox object as a parameter
}
else {
$ck.attr(" checked", "");
$("[name='ck']:checkbox").attr("checked", "");
var ff = $ck.val();
var cc = $ck.get(0);
window[ff](cc);
}
}
else//As a choice
{
if ($ ck.attr("checked") == false) {
$ck.attr("checked", "checked");
var s = $ck.val();
var a = $ ck.get(0);
window[s](a);
}
else {
$ck.attr("checked", "");
var s = $ ck.val();
var cb = $ck.get(0);
window[s](cb);
}
}
})
})
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn