Can't append [removed] element

后端 未结 18 2241
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 06:11

Any idea why the piece of code below does not add the script element to the DOM?

var code = \"\";
$(\"#someElement\").append(cod         


        
18条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-21 06:38

    I tried this one and works fine. Just replace the < symbol with that \x3C.

    // With Variable
    var code = "\x3Cscript>SomeCode\x3C/script>";
    $("#someElement").append(code);
    

    or

    //Without Variable
    $("#someElement").append("\x3Cscript>SomeCode\x3C/script>");
    

    You can test the code here.

提交回复
热议问题