Convert HTML string into Jquery Object

前端 未结 2 1235
不知归路
不知归路 2021-02-12 12:25

I have a HTML string which is a mix of text plus HTML tags, which i\'m trying to convert into an object. So for e.g. my HTML string would look like:

Pay using yo         


        
2条回答
  •  不思量自难忘°
    2021-02-12 12:40

    $.parseHTML() parses a string into an array of DOM nodes.

    To create the object you need to add $():

    $($.parseHTML(yourString))
    

    Take a look at this fiddle: http://jsfiddle.net/j05ucnfv/

    Reference: http://api.jquery.com/jQuery.parseHTML/

提交回复
热议问题