【发布时间】:2013-05-12 11:06:06
【问题描述】:
当使用 jQuery 按下“Go”按钮时,我正在尝试从文本区域替换页面标题。我还没有成功。我尝试了replaceWith(),但是没有用,所以我尝试了这个:
test.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>`
go.js:
$(function go() {
var title = document.getElementById('title').value();
document.title = title;
});
【问题讨论】:
-
下次您可以简单地使用四 (4) 个空格作为代码块,并在行尾乘以 (2+) 个空格作为换行符。
-
使用谷歌怎么样?通过简单的良好搜索,这就是我发现的:stackoverflow.com/questions/987967/…
-
只需删除 $( 和 );来自 go.js &try
-
我正在寻找同样适用于更新网站图标的解决方案。
标签: javascript jquery html