单击时文本框重定向

Textbox redirect on click

当用户在文本区域中单击(不单击 sumbit 按钮)时,如何制作一个带有单击重定向的文本框?

 <form method="POST">
  <input id="textboxsearch" type='text' value=''>
  <input type="submit" value="Submit">
 </form>

您可以使用 Javascript 执行此操作。使用库 jQuery:

甚至会更容易
<script>
    $(function(){
        $('#textboxsearch').click(function(){
            $('form').submit();
        });
    });
</script>

如果您以前从未使用过 jQuery,这里有一个简短的介绍:

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

您可以像这样将其包含在他们的 CDN 中:

<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>

但是为什么您希望用户在输入内容之前被重定向?