用数据来创建表格
var data = [
{ name: 'jim', age: 19, gender: 'male'},
{ name: 'jim', age: 19, gender: 'male'},
{ name: 'jim', age: 19, gender: 'male'},
{ name: 'jim', age: 19, gender: 'male'},
{ name: 'jim', age: 19, gender: 'male'},
{ name: 'jim', age: 19, gender: 'male'}
];
// 创建 table
$( '<table border="1"><tbody>' + $.map( data, function ( v, i ) {
return '<tr>' + $.map( v, function ( v1, i1 ) {
return '<td>' + v1 + '</td>'
}).join( '' ) + '</tr>';
}).join( '' ) + '</tbody></table>' ).appendTo( 'body' );
$( 'td' ).css( {
'100px',
height: '50px'
});
$( 'tr' ).mouseover(function () {
// this 是 DOM 对象
$(this).css( 'backgroundColor', 'yellow' );
}).mouseout(function () {
$(this).css( 'backgroundColor', '' );
});