jquery的元素替换操作

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div class="box">111</div>
    <div class="box">222</div>
    <span>hi</span>
    <script src="lib/jquery-2.2.2.js"></script>
    <script>
        // $('.box').replaceWith('<p>hello</p>');
        // $('.box').replaceWith($('span'));
        $("<a href=''>Link</a>").replaceAll('span');
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_44606660/article/details/88197973