Skip to content

hover effect is missing after replaceWith #94

Description

@lzl124631x

// html

            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <meta http-equiv="X-UA-Compatible" content="IE=7" />
                <title></title>
                <link type="text/css" href="changeElement-hover.css" rel="stylesheet" />
                <script type="text/javascript" src="Scripts/jquery-1.11.1.min.js"></script>
                <script type="text/javascript" src="Scripts/selectivizr-min.js"></script>
                <script>
                    $(function () {
                        function updateText() {
                            $(this).text('newnewnewnewnewnewnewnewnewnewnew');
                        }

                        function updateBox() {
                            $(this).replaceWith($('<span class="box">newnewnewnewnewnewnewnewnewnewnew. </span>'));
                        }

                        $('.box').click(updateBox);
                    })
                </script>
            </head>
            <body>
                <span class="box">oldoldoldoldoldoldoldoldoldoldoldoldoldold. </span><span class="box">oldoldoldoldoldoldoldoldoldoldoldoldoldold. </span>
            </body>
            </html>

// css

        .box {
            cursor: pointer;
            font-style: italic;
        }

            .box:hover {
                background-color: yellow;
            }

            .box:last-child {
                color: red;
            }

The above code illustrates a bug: after new element substitutes the old one by replaceWith, the hover effect is missing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions