输入激活文本字段中的链接

时间:2014-04-23 15:54:01

标签: javascript css forms hyperlink textbox

我在这里查看了各种问题,并且找不到任何对我有用的东西,或者我不知道要编辑它的内容使它工作。

我有一个文本框,用户可以在其中输入内容,然后他们可以点击按钮或按回车键,然后将它们带到特定页面。我正在模拟未来的功能。我想要它,以便当用户按下回车或点击按钮时,无论他们输入什么内容,它都将转到同一页面。

当然,按钮工作,当然,但我无法想出按下输入工作。这是我到目前为止在HTML

中所拥有的
<input type="text" class="search" form="form1" onfocus="if (this.value=='City, State') this.value='';" value="City, State"/>
<a href="Springfield.html"><img src="images/searchbutton.png" class="searchbutton"/></a>

非常感谢对此的任何帮助

1 个答案:

答案 0 :(得分:0)

将您的元素嵌套在form中,并从form移除input属性:

<form action="Springfield.html">
    <input type="text" class="search" onfocus="if (this.value=='City, State') this.value='';" value="City, State"/>
    <a href="Springfield.html"><img src="images/searchbutton.png" class="searchbutton"/></a>
</form>
相关问题