Get selected element's outer HTML

前端 未结 30 2351
礼貌的吻别
礼貌的吻别 2020-11-21 04:50

I\'m trying to get the HTML of a selected object with jQuery. I am aware of the .html() function; the issue is that I need the HTML including the selected obje

30条回答
  •  礼貌的吻别
    2020-11-21 05:00

    You can find a good .outerHTML() option here https://github.com/darlesson/jquery-outerhtml.

    Unlike .html() that returns only the element's HTML content, this version of .outerHTML() returns the selected element and its HTML content or replaces it as .replaceWith() method but with the difference that allows the replacing HTML to be inherit by the chaining.

    Examples can also be seeing in the URL above.

提交回复
热议问题