jQuery internally maps '<tagName>' to document.createElement( 'tagName' ). This is a feature, and is used throughout jQuery internally. It's not very well documented as such, but Timo is adding it to the documentation as to resolve the confusion around this. $( '<div>' ) is a shortcut added to jQuery for our convenience, and I think it's reasonable to use it.
On Tue, Aug 28, 2012 at 10:44 AM, Mark Holmquist <[email protected]>wrote: > In creating elements, maybe, but after creation, $.prop() is the preferred > way to go because the DOM properties are more reliably synced with the > actual state of the UI--apparently jQuery doesn't always properly sync the > HTML attributes to the browser state. I'm sure Timo can explain more fully > (and maybe more accurately). > We had this discussion yesterday, and addClass is more direct than prop( 'className' ) in every way and unless you mean to actually replace all existing classes, addClass is preferred. prop is there for a reason and it's also safe to use as escaping goes, but obviously not all attributes are actually properties, so it's not like we should stop using attr. - Trevor _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
