This time I will bring you JQueryWhat are the techniques for operating the table, what are the precautions for operating the JQuery table, the following is a practical case , let’s take a look.
1. Add styles to the odd and even rows of the table respectively
$(function(){ $('tr:odd').addClass("odd"); $('tr:even').addClass("even"); });
Not counting the header of the table
$(function(){ $('tbody>tr:odd').addClass("odd"); $('tbody>tr:even').addClass("even"); });
2. The radio button controls the highlighting of rows
$('tobdy>tr').click(function(){ $(this).addClass('selected') .siblings().removeClass('selected') .end() // 重新返回该 对象 .find(':radio').attr('checked',true); });
3. Check boxControl row highlighting
$('tobdy>tr').click(function(){ if( $(this).hasClass('selected') ){ // 判断是否有selected高亮样式 $(this).removeClass('selected') .find(':checkbox').attr('checked',false); }else{ $(this).addClass('selected') .find(':checkbox').attr('checked',true); } });
4. Table content filtering
$(function(){ $('table tbody tr').hide() .filter(":contains(李)").show(); });
I believe you have mastered the method after reading the case in this article , for more exciting content, please pay attention to other related articles on the php Chinese website!
Recommended reading:
JQuery dynamically operates table rows and adds events to new rows
The above is the detailed content of What are the techniques for operating JQuery tables?. For more information, please follow other related articles on the PHP Chinese website!