html - Keep values fom labels by jquery after page refresh -
hello got code
<div class="values"><span>labels :</span><span class="selected"></span> </div> <div id='main'> <div class="data"> <div class="values"> <div> <p> <label data-name="1">a</label> <input type="checkbox" value="1" /> </p> </div> <div> <p> <label data-name="2">b</label> <input type="checkbox" value="2" /> </p> </div> <div> <p> <label data-name="3">c</label> <input type="checkbox" value="3" /> </p> </div> </div> </div> <div class="data"> <div class="values"> <div> <p> <label data-name="1">d</label> <input type="checkbox" value="1" /> </p> </div> <div> <p> <label data-name="2">e</label> <input type="checkbox" value="2" /> </p> </div> <div> <p> <label data-name="3">f</label> <input type="checkbox" value="3" /> </p> </div> </div> </div> </div>
js
function labelsvalue(selected) { var selected = $('#main input[type="checkbox"]').filter(':checked').map(function() { return $.trim($(this).next().attr('data-name')); }).get(); $('.labels .values').text(selected.join(', ')); } $('input').on('change', function() { labelsvalue($(this)); });
and have dynimicly display values labels chekcbox click, when refresh page checkboxes checked lables not read. data label , input read php arrays.
how change code red values labels jquery after page refresh.
you can use html5 local storage or session storage remember label values after page refresh.
Comments
Post a Comment