最最最簡單的全選功能基於(jquery)

今天在寫全選功能的時候發現一個全選非常簡單的,就記錄一下,大家可以直接使用,複製到js代碼裏邊就可以了。(ps:什麼動不用改

 

$('table th input:checkbox').on('click', function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});

實現圖片:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章