当前位置:网站首页>JS use the Icheck plug-in to listen and get the value of the checkbox

JS use the Icheck plug-in to listen and get the value of the checkbox

2022-06-10 12:15:00 BlizzardWu

HTML:

<tbody class="text-c tbody" id="tbody">
{foreach $order as $v}
	<tr class="info_tr " jwid="{$v.id}" tit="{$v.title}">
    	<td ><input id="is_show_{$v.id}" class="is_show" type="checkbox" name="is_show" {if condition="$v.is_show eq 1"}checked{/if} value="{$v.is_show}" eid="{$v.id}"></td>
     	<td>{$v.title}</td>
 	</tr>
{/foreach}
</tbody>

javascript:

$(".is_show").on('ifClicked', function(event){
      
   //  From this place checked Contrary to reality , Because the click event happened before the real change , Therefore, it is necessary to take the opposite 
    var multiSelect = event.target.checked ? 0 : 1;
    // console.log(event.target);
    //  Modify as selected value value 
    if(multiSelect == 1){
    
        event.target.value = 1;
    }else{
    
        event.target.value = 0;
    }
});
原网站

版权声明
本文为[BlizzardWu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101206512860.html