How can I check check-boxes (on page load) according to value of check-boxes using jQuery? I have list of values that I have stored within localstorage (Long live HTML5 !!) A sample data would be
something_random|something_random2|something_random3
And basically I want to read each value and make sure onload checkboxes that already have those values are checked.
I have already written;
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 didn't work...How can I fix it?