Javascript-js How to implement the following functions

Source: Internet
Author: User
    1. Describe your problem
      I would like to do a search box similar to the following, when the user enters a value, click on the options above will jump to different links,

Such as

For example, I enter QQ,
Click on the "News" above, will jump to NEWS.SOGOU.COM/?KW=QQ
Or click on the "" above and jump to HWEIXIN.SOGOU.COM/?KW=QQ
Or click on "Ask" above. Will jump to WENWEN.SOGOU.COM/?CID=QQ
.........
When the user enters a value, click on the option above to jump to a different link, with javascript+html how to write. Trouble with complete code. Thank you. I do the art,

Reply content:

    1. Describe your problem
      I would like to do a search box similar to the following, when the user enters a value, click on the options above will jump to different links,

Such as

For example, I enter QQ,
Click on the "News" above, will jump to NEWS.SOGOU.COM/?KW=QQ
Or click on the "" above and jump to HWEIXIN.SOGOU.COM/?KW=QQ
Or click on "Ask" above. Will jump to WENWEN.SOGOU.COM/?CID=QQ
.........
When the user enters a value, click on the option above to jump to a different link, with javascript+html how to write. Trouble with complete code. Thank you. I do the art,

window.location.href = "Your url"

JS can implement dynamic adjustment form of the action value, HTML can be as follows:

    新闻    网页    

The navigation menu here can also be generated dynamically, that is, the use of variable definitions in the JS script, and then JS to output. The script assumes that writing is used jQuery .

Next to my idea, input box onkeyup event, get input box value, then event delegate, change href to original address + keyword
The demo is as follows:

  
  
     
  
     JS Bin新闻搜索

Online demo point here, about the URL after the redirection of the construction rules, the main topic to look at, each site is not the same

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: [email protected] and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.