$('') vs $('') in jQuery

后端 未结 6 740
暗喜
暗喜 2020-11-29 13:10

I see people creating HTML elements in jQuery in two different ways:

$(\'\')

and

$(\'\') 
<         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 13:49

    There is no difference, as seen in the source code, line 30 & line 121:

    /* Line 30*/
    rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
    
    /* Line 121 */
    // If a single string is passed in and it's a single tag
    // just do a createElement and skip the rest
    ret = rsingleTag.exec( selector );
    

    The following are equivalent:

提交回复
热议问题