jQuery Append String vs Object Containing String

后端 未结 2 769
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 15:01

I understand that both of these will insert html into an element.

What are the differences between these 2 methods though?

String:

$(\"div\").app         


        
2条回答
  •  -上瘾入骨i
    2021-01-22 15:35

    In your example there's no practical difference. The function accepts strings because you might want to add a new element which doesn't have a jQuery object yet, and it accepts jQuery objects because you might want to append an existing element or a complex object that doesn't have a string representation.

提交回复
热议问题