当使用 jQuery 按下“Go”按钮时,我正在尝试从文本区域替换页面标题。我还没有成功。我尝试了replaceWith(),但是没有用,所以我尝试了这个:
测试.html:
<html>
<head>
<title>Test</title
<script src="jQuery.min.js"></script>
<script src="go.js"></script>
<link id="si" rel="shortcut icon" media="all" type="image/x-icon" href="http://www.google.com/favicon.ico" />
<!-- This was for trying to change the icon (also unsuccessful) -->
<link id="i" rel="icon" media="all" type="image/vnd.microsoft.icon" href="http://www.google.com/favicon.ico" />
</head>
<body>
<textarea id="title">Type the new title.>;/textarea>
<!-- Put the favicon switcher here -->
<button onclick="go()">Go</button>
<br />
</body>
</html>`
去.js:
$(function go() {
var title = document.getElementById('title').value();
document.title = title;
});