Setting checkbox input when specific value equals variable in jquery -


i trying use jquery set checkbox checked if input value of checkbox equal other variable have. code looks like:

var test_val = "test"; $('#checkbox[value='+test_val+']').attr('checked', true); 

this not seem working, help

try this

$('#checkbox[value="'+test_val+'"]').attr('checked', true); 

you missing quotes around value.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -