【问题标题】:Search an element from the form element using css使用 css 从表单元素中搜索元素
【发布时间】:2017-06-05 08:04:33
【问题描述】:

为了创建一个搜索标签,我执行了以下操作:

<form>
   <input type="text" name="search" placeholder="Search..">
</form> 

但是,如果我想从同一个 html 页面中搜索另一个元素,比如使用此搜索选项卡说一个名为“123”的段落,我该如何继续?

【问题讨论】:

  • 您的问题不清楚。请放一个sn-p。
  • 您在问是否如何使用IDnameclass 使用input 搜索另一个元素,对吧?
  • 是的,可以使用输入元素搜索任何元素
  • 我相信你需要使用 JavaScript 来完成这个任务:document.querySelector('input[name=search]').addEventListener('input', function(event) { console.log(document.getElementById(event.target.value)) })
  • 你能告诉我在 html 脚本中在哪里添加这个 java 命令,比如在表单标签或输入标签之后等等? @wostex

标签: html css forms input


【解决方案1】:

很简单,请给这个答案5分!!!

input[type=text]
{
background-color:green;
font-size:40px;
}
input[type=email]
{
background-color:red;
font-size:40px;
}
<form>

<input type=text placeholder="i an text and i am green"><br>
<input type=email placeholder="i an email and i am red"><br>


</form>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2016-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 2012-03-22
    相关资源
    最近更新 更多