Skip to content

With [prevAll] and then with [wrapAll], the order of the nodes in the dom changes #5149

@lovecodeyou

Description

@lovecodeyou

Bug Reports:
With [prevAll] and then with [wrapAll], the order of the nodes in the dom changes

Description

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
</head>
<body>
    <div id="row" style="border: 1px solid black;">
        <span>【one】</span>
        <span>【two】</span>
        <span id="middle">【middle】</span>
        <span>【three】</span>
        <span>【four】</span>
    </div>


    <div id="jqueryChange" style="border: 1px solid black;margin-top: 50px;">
        <span>【one】</span>
        <span>【two】</span>
        <span id="middle">【middle】</span>
        <span>【three】</span>
        <span>【four】</span>
    </div>    
</body>

<script>

    $(function() {

        $("#jqueryChange #middle").each(function () {
                    $(this).prevAll()
                        .wrapAll("<p/>")
                        .end()
                        .nextAll()
                        .wrapAll("<p/>")
        })

    })

</script>

</html>

image

Link to test case

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions