且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery创建整个DOM结构

更新时间:2023-12-05 15:05:40


  1. 不要使用作为您的HREF;使用真实链接,并从您的点击事件处理程序返回false。此外,如果这只是为某些GUI元素供电,我强烈建议不要使用A(anchor)标签,因为锚标签用于LINKS,而不是GUI控件。如果您需要GUI控件,请使用输入按钮(这就是他们为此而设计的)。

  2. 选择器可能会受益于某些情况;例如如 $('select.advancedOptionsPicker') $('。advancedOptionsPicker','#optionsPickerContainer')

  3. 可能会在构建&             手动附加大量HTML。

  1. Never use # as your HREF; use a real link, and return false from your click event-handler. Also, if this is simply to power some GUI element, I highly recommend against using an A (anchor) tag, as anchor tags are meant for LINKS, not GUI controls. If you need a GUI control, use an input button (that's what they were made for!).
  2. The selector $('.advancedOptionsPicker') would likely benefit from some context; e.g. something like $('select.advancedOptionsPicker') or $('.advancedOptionsPicker', '#optionsPickerContainer').
  3. You might want to look into Document Fragments when constructing & appending lots of HTML manually.