jQueryã§ã¯DOMçæã«jQuery(html, props)ã¨ããæ§æã使ãã¾ããâã®ããã«ç°¡æ½ã«æ¸ãã¾ãã
-$('<div class="bar">foo</div>');
â
+$('<div/>', {'class': 'bar', 'text': foo'});
ãã ãinputè¦ç´ ã«éã£ã¦ã¯åé¡ãããã®ã§æ³¨æããªãã¨ããã¾ããã
ããã¯æããã£ããã¨ãããï¼ããã°è¨äºãæ¸ããï¼ã®ã§ãããinputè¦ç´ ã®typeå±æ§ã¯ä¸æ¸ãã§ãã¾ãããtype="password"ãtype="text"ã«å¤æ´ãããªãããã«ãã¦ããã®ã ã¨æãã¾ãã
ãã®ãããhttp://api.jquery.com/jQuery/#creating-new-elements title:Creating New Elementsã®Unsupported IEã®é
ç®ã§ã¯
-$('<input />', {type: 'text', name: 'test'}).appendTo("body");
+$('<input type="text" />').attr({name: 'test'}).appendTo("body");
ã¨æå°ããã¦ãã¾ããç§ã¯ãã®é¨åãè¥å¹²é©å½ã«èªã¿æµãã¦ãã¦ã
'<input type="text" />'
ã¨ããæ¸ãã°è¯ãã®ã ã¨æã£ã¦ãã¾ãããããã§ãåé ã§ç´¹ä»ããjQuery(html, props)ã使ã£ã¦
$('<input type="text"/>',{name: 'test'}).appendTo("body");
ã¨æ¸ãã¦ãã¾ãã¾ããã
ããã¨
> "ãªãã¸ã§ã¯ã㯠'createDocumentFragment' ããããã£ã¾ãã¯ã¡ã½ããããµãã¼ããã¦ãã¾ããã"
ã¨ã®ãè¨èãé ããã¾ãããinputå¨ãã§ããããã¨ã«ãªã£ãã®ã§ãã
jQueryã§ã®æ°è¦inputè¦ç´ ãæ£ããæ¸ãã«ã¯
jQuery('<input/>')
ã§ã¯ãªã
jQuery('<input type="text"/>', props)
ã§ããªã
jQuery('<input type="text"/>').attr(props)
ã¨æ¸ããªããã°ãªããªãã®ã§ãã