i'm trying find jq alternative script link see exampe problem want use classes instead of ids, , single div can have more 1 class, can displayed after checking checkbox1 or checkbox2 or both of them. idea how make works ?
function toggle(matchingattribute) { // optain div elements in page var divarray = document.getelementsbytagname("div"); for(i=divarray.length-1; i>=0; i--) { // each div if(divarray[i].id.match("_"+matchingattribute+"_")) { if(divarray[i].style.display != 'none') { divarray[i].style.display = 'none'; } else { divarray[i].style.display = ''; } } } } // end function toggle()
try
$('.chk').click(function(){ var classname = $(this).attr('data-class'); if ($(this).is(':checked')) { $('.'+classname+'').show(); } else { $('.'+classname+'').hide(); } });
Comments
Post a Comment