当前位置:网站首页>Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog

Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog

2022-07-06 16:39:00 Feng Hao (grow up)

Ideas :
First call jq file
When we click Select all, we let them all be true
When clicking none of them, we let them all be false
When you click invert Use echo Loop traversal checked Use ! Take the opposite ;

html part 
	<input type="checkbox">
	<input type="checkbox">
	<button > Future generations </button>
	<button > Not all </button>
	<button'> Reverse election </button>
js part 
	//  Click Select all 
	$('button:first').click(function(){
		$(':checkbox').prop('checked',true);
	})
	
	//  Click none    eq: Get inverse selection button 
	$('button:eq(1)').click(function(){
		$(':checkbox').prop('checked',false);
	})
	
	//  Click invert 
	$('button:last').click(function(){
		$(':checkbox').each(function(index,item){
			item.checked = !item.checked;
		})
	})

 Insert picture description here

原网站

版权声明
本文为[Feng Hao (grow up)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060920252132.html