Home > Web Front-end > JS Tutorial > Precautions for jquery traversing checkbox_jquery

Precautions for jquery traversing checkbox_jquery

WBOY
Release: 2016-05-16 16:58:56
Original
942 people have browsed it

When I was working on a front-end project these two days, I wanted to traverse the checkbox on the page through jquery, using the following code:

Copy the code The code is as follows:

var val_instanceCodeStr = "";

$("input[type='checkbox'] [name='chk_jvmMachineName']:checked").each(
function() {
val_instanceCodeStr = "," $(this).val( );
}
);


The variable val_instanceCodeStr is still an empty string at the end, and the function function is not executed;

After checking the information online and comparing it, I found that the code was written correctly. Finally, I found that there was an extra space between [type='checkbox'] [name='chk_jvmMachineName'], which resulted in the checkbox object not being obtained

Jquery multiple selectors cannot be separated by spaces

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template