用jquery的id選擇器的text()方法,取不到想要的字符串;試了一下用原生js也是一樣的;
代碼如下;
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body id="body" style="display: none">
%0A%3C%21--%u6B64%u7F51%u9875%u5DF2%u52A0%u5BC6%uFF0C%u6B32%u89E3%u5BC6%u8BF7%u5230code.qcgzxw.cn/html.html%u89E3%u5BC6--%3E%0A%3Cform%3E%0A%20%20%20%20%3Ctr%3E%0A%20%20%20%20%20%20%20%20%3Ctd%3Edd%3C/td%3E%0A%20%20%20%20%20%20%20%20%3Ctd%3Eff%3C/td%3E%0A%20%20%20%20%20%20%20%20%3Ctd%3Ecc%3C/td%3E%0A%20%20%20%20%3C/tr%3E%0A%3C/form%3E%0A%3C%21--%u6B64%u7F51%u9875%u5DF2%u52A0%u5BC6%uFF0C%u6B32%u89E3%u5BC6%u8BF7%u5230code.qcgzxw.cn/html.html%u89E3%u5BC6--%3E%0A
</body>
</html>
<script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
<script>
/**
*
* @constructor
*/
function OutWord()
{
var Words = $("#body").text();
var NewWords;
console.log(Words);
NewWords = unescape(Words);
console.log(NewWords);
$("#body").html(NewWords).css("display", "block");
}
OutWord();
</script>
為什么$("#body").text()會(huì)取到script標(biāo)簽里的東西?
/**
*
* @constructor
*/
function OutWord()
{
var Words = $("#body").text();
var NewWords;
alert(Words);
console.log(Words);
NewWords = unescape(Words);
console.log(NewWords);
$("#body").html(NewWords).css("display", "block");
}
OutWord();
這個(gè)是什么原理,之前沒遇到過這種情況;
求助;
- 4 回答
- 0 關(guān)注
- 574 瀏覽
添加回答
舉報(bào)
0/150
提交
取消