首页 > 解决方案 > Google 手气不错的按钮

问题描述

我是学习 HTMl 编码的新手,我想通过复制https://www.google.com/页面来训练自己。因此,我添加了输入以让用户进行研究。

我想提供两种不同类型的研究(就像在谷歌页面中一样)。在第一个中,通过点击“Google Search”提交输入,用户正在做一个经典的研究。而在第二个中,当用户点击“我感觉很幸运”提交输入时,用户会直接被带到第一个链接,如果用户进行了经典研究,该链接会出现。

但问题是,这两个提交输入都给了我一个“经典研究”,在这个论坛和其他论坛中寻找了很多答案之后,我仍然不明白为什么我的 html 代码不起作用:

<!DOCTYPE html>
<html lang="en">

    <head>
        <title>Google</title>
        <link rel="stylesheet" href="style.css">
        <link rel="shortcut icon" type="image/x-icon" href="google_logo.png">
    </head>
    <body>
        <div class="ends">
            <a id="left" href="ggimage.html">Google image</a>
            <a id="right" href="ggladvanced_search.html">Google advanced search</a>
        </div>
        <br><br><br><br><br><br><br><br>
        <div>
            <img src="google_search.PNG" alt="Google Search">
            <form action="https://google.com/search">
                <input type="text" name="q" placeholder="Enter your research">
                <div>    
                    <input id="right" name="btnK" type="submit" value="Google Search">
                    <p style="width: 10px;"></p>
                    <input id="left" name="btnI" type="submit" value="I'm Feeling Lucky"> 
                </div>
            </form>
        </div>
    </body>
</html>

我尝试使用按钮而不是提交输入,但它显示了相同的结果。

标签: htmlinput

解决方案


问题是您让<input type="text"...>标签处于打开状态。关闭它,您的表单应该按预期工作。

改变这个: <input type="text" name="q" placeholder="Enter your reshearch">

对此: <input type="text" name="q" placeholder="Enter your research"/>


推荐阅读