jQuery what is the difference between $('

') and $('p')

后端 未结 3 527
野的像风
野的像风 2021-01-23 09:46

Can someone explain to me the difference between $(\'

\') and $(\'p\') in jQuery.

for example, if i write:

$(\'body\').         


        
3条回答
  •  时光取名叫无心
    2021-01-23 10:14

    $('

    ') creates a new paragraph (

    ) element. (

    )

    $('p') selects all existing paragraph elements.

    For example:

    $('p').after($('

    ').html('foo'))

    Will select all paragraphs and add new paragraphs after them.

提交回复
热议问题