How do you convert a jQuery object into a string?

前端 未结 12 1867
臣服心动
臣服心动 2020-11-22 15:07

How do you convert a jQuery object into a string?

12条回答
  •  醉酒成梦
    2020-11-22 15:20

    The best way to find out what properties and methods are available to an HTML node (object) is to do something like:

    console.log($("#my-node"));
    

    From jQuery 1.6+ you can just use outerHTML to include the HTML tags in your string output:

    var node = $("#my-node").outerHTML;
    

提交回复
热议问题