1. Add styles
$ (function(){
$('tr:odd').addClass("odd");
$('tr:even').addClass("even");
});
Does not count the head of the table
$(function(){
$('tbody>tr:odd').addClass("odd");
$('tbody>tr:even').addClass("even");
});
2. Highlighting of radio button control rows
$('tobdy>tr').click(function(){
$(this).addClass('selected')
.siblings() .removeClass('selected')
.end() // Return the object again
.find(':radio').attr('checked',true);
});
3. Check box control row highlighting
$('tobdy>tr').click(function(){
if( $(this).hasClass('selected') ){ // Determine whether there is a selected highlight style
$(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();
});