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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -