donglengyuan6826 2016-10-14 10:27
浏览 82
已采纳

单个搜索上的三个操作按钮

I am building a website on WordPress, there is a search button as seen below in image. enter image description here

I want if a user fills "Japan" in search box ...condition:

  1. If the user clicks on the search button then show all result of "Japan" in website (which is done)
  2. If the user clicks on the YouTube icon then videos related to "Japan" are shown
  3. If the user clicks on the Wikipedia Link then all information of "Japan" on Wikipedia is shown.

That means that the user can enter anything in search and then search that keyword:

  • on the site, or
  • on YouTube, or
  • on Wikipedia.

The single keyword should work for all buttons.

  • 写回答

1条回答 默认 最新

  • doushih06137 2016-10-14 13:24
    关注

    Well. First of all, I would try to make it somewhat more clear what you actually want to do. As of this, there might be a risk that I misunderstood you, but if I understood you correctly, this is my answer:

    You have three buttons:

    Html:

    <div>
        <button id="wikiButton">Wiki icon</button>
        <button id="youtubeButton">Youtube icon</button>
        <button id="searchButton">Search locally</button>
    </div>
    

    script:

    document.getElementById('wikiButton').addEventListener('click', function () {
    Do wiki thing
    }
    
    document.getElementById('youtubeButton').addEventListener('click', function () {
    Do youtube thing
    }
    
    document.getElementById('searchButton').addEventListener('click', function () {
    Do locally search thing
    }
    

    Alternatively you could assign an onclick="doThis()" handler to each button, which each holds a function that does what you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥50 大二 微机原理 课程design 有偿