Get and Set Cookie from multiple to style multiple (li)s

I want to the user when he select multiple input the jquery set a cookie then add my class to specific li where the value of the cookie is equal to the (data-id) of the li>>> please I need your help on this matter>>>

 $(document).ready(function(){
$("input").change(function() {
if ($(this).is(':checked')) {
    $("li").filter('[data-id='+this.value+']').addClass('prelight');
    createCookie(this.name, this.value, 1000);
} else {
   $("li").filter('[data-id='+this.value+']').removeClass('prelight');
    eraseCookie(this.name, this.value);
}
});

if (readCookie(this.name)) {
$("li").filter('[data-id='+this.value+']').addClass('prelight');
$('input').filter('[name='+this.name+']').attr('checked', 'checked');
}
});

for more details, please see this http://jsfiddle.net/4pf8hsgf/


Source: css

Leave a Reply