jquery获得包含自身在内的html元素

xiaoxiao2021-02-28  99

$(”).html()是获得选中元素下的子节点的html,不能包含自身元素。 反之,我们要把更改包含选中自身的元素的html代码的时候,可像下面这样写

<div class="test"><p>hello,你好!</p></div> <script> $(".test").prop("outerHTML"); </script>

jquery设置outerhtml

<script> $(".test").prop("outerHTML",'<imput>'); </script>
转载请注明原文地址: https://www.6miu.com/read-94851.html

最新回复(0)