这就是我想要做的事:的jQuery导航从文本输入到一个网页名(.htm)
我有一个网站上的某些页面(脱机演示) 当你在输入“联系”输入栏并点击'提交',我想 去contact.htm。
我发现类似的东西here(学分)
的jQuery:
jQuery(function() {
$(document).ready(function() {
function goTo() {
window.location = where.value + '.htm';
return false;
}
});
HTML:
<form action="" method="post" onsubmit="return goTo()">
<input type="text" name="where" value="looking for"
onfocus="if(this.value == this.defaultValue) this.value = '';
"onblur="if(this.value == '') this.value = this.defaultValue;">
<input type="submit" value="Go">
</form>
我对你的问题是;提交输入后,此代码根本无法导航。
这是正确的做法吗? :window.location = where.value + '.htm';
当然,这是有道理的。 jQuery如何识别它是关于htm页面的? – Opoe