高效的jQuery代码编写技巧

使用单引号 不推荐 $("div").html("<img src='1.jpg'>"); 推荐 $('div').html('<img src="1.jpg">'); 缓存变量 DOM遍历是昂贵的,所以尽量将会重用的元素缓存。 // 糟糕 h = $('#element').height(); $('#element').css('height',h-20); // ...