var odv = $.create("div");
$.append(odv);
this.$OuterDiv = $('<div></div>')
.hide()
.append($('<table></table>')
.attr({ cellSpacing : 0 })
.addClass("text")
)
;
Update: I thought I'd update this post since it still gets quite a bit of traffic. In the comments below there's some discussion about $("<div>")
vs $("<div></div>")
vs$(document.createElement('div'))
as a way of creating new elements, and which is "best".
I put together a small benchmark, and here's roughly the results of repeating the above options 100,000 times:
jQuery 1.4, 1.5, 1.6
Chrome 11 Firefox 4 IE9
<div> 440ms 640ms 460ms
<div></div> 420ms 650ms 480ms
createElement 100ms 180ms 300ms
jQuery 1.3
Chrome 11
<div> 770ms
<div></div> 3800ms
createElement 100ms
jQuery 1.2
Chrome 11
<div> 3500ms
<div></div> 3500ms
createElement 100ms
출처:
http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent
'Technology > Programming' 카테고리의 다른 글
jQuery / 이벤트, 셀렉터, DOM 관련 함수, AJAX 정리 (0) | 2011.11.30 |
---|---|
PHP / 날짜 다루기 (0) | 2011.11.26 |
Web / 웹 개발 시 조심해야할 것들 (0) | 2011.07.18 |
Python / R 과 연동하여 Rank normalization 구하기 (0) | 2011.03.02 |
Python / Divide GDS of GEO into GSM values. (0) | 2011.02.18 |