《如何提高JQuery代码效率》.pdfVIP

  • 2
  • 0
  • 约5.87千字
  • 约 5页
  • 2018-03-24 发布于河南
  • 举报
《如何提高JQuery代码效率》.pdf

1. 总是从ID 选择器开始继承 在jquery 中最快的选择器是ID 选择器. 因为它直接来自于Javascript 的getElementById 方法. div id “content” form method “post” action “/” Traffic Light ul id “traffic_light” input type “radio” class “on” name “light” value “red” / Red input type “radio” class “off” name “light” value “yellow” / Yellow input type “radio” class “off” name “light” value “green” / Green input class “button” id “traffic_button” type “submit” value “Go” / 像这样选择按钮是低效的: var traffic_button $ ‘#content .button’ ; 用ID 直接选择按钮效率更高: var traffic_button $ ‘#traffic_button’ ; 选择多个元素 提到多元素选择其实是在说DOM 遍历和循环, 这些都是比较慢的东西.为了提

文档评论(0)

1亿VIP精品文档

相关文档