How can I check the checkboxes (when the page loads) according to the value of the checkboxes using jQuery? I have a list of values that I saved in localstorage (Long live HTML5!). Data samples will be
something_random|something_random2|something_random3
And basically, I want to read each value and make sure that the onload flags that already have these values are checked.
I already wrote:
my_cookie=localStorage.getItem('chosen_ones');
$.each(my_cookie.split("|"), function(index, values) {
if((values==val)&&(values!=null)&&(values!="")&&(values!="null")&&(values!="")){
$('input[value='+values+'').attr('checked', true);
}
});
However, this did not work. How can i fix this?
source
share