Html 你如何看待用户';s输入并将其添加到iframe中的URL?
我正试图建立一个网站,有多个搜索引擎,并比较结果 到目前为止我有Html 你如何看待用户';s输入并将其添加到iframe中的URL?,html,forms,iframe,Html,Forms,Iframe,我正试图建立一个网站,有多个搜索引擎,并比较结果 到目前为止我有 <!DOCTYPE html> <html lang="en"> <head> <title>fact checker</title> </head> <body> <form method="get" action="https://www.dogpile.com/search"&g
<!DOCTYPE html>
<html lang="en">
<head>
<title>fact checker</title>
</head>
<body>
<form method="get" action="https://www.dogpile.com/search">
<input type="text" name="q" size="31" value="">
</form>
<iframe id="Dogpile"
title="Dogpile"
width="1000"
height="1500"
src="https://www.dogpile.com">
</iframe>
</html>
我不打算把它放到网上,我只是为了练习编码
谢谢您可以使用document.querySelector进行输入
> let input = document.querySelector('input[name="q"]')
如果您想将其添加到表单动作中,可以使用
$('form').on('submit',(el)=>{
//Here we select currentTarget value(input value)
let input = document.querySelector('input[name="q"]')
//Here we change action form, .attr() with 1 param you get value of attr, if you
//put a second param you set the value of that attribute
$('form').attr('action',$('form').attr('action')+input)
})
代码在$('form').on()上所做的是获取其值并添加输入值
您可以使用document.querySelector进行输入
> let input = document.querySelector('input[name="q"]')
如果您想将其添加到表单动作中,可以使用
$('form').on('submit',(el)=>{
//Here we select currentTarget value(input value)
let input = document.querySelector('input[name="q"]')
//Here we change action form, .attr() with 1 param you get value of attr, if you
//put a second param you set the value of that attribute
$('form').attr('action',$('form').attr('action')+input)
})
代码在$('form').on()上所做的是获取其值并添加输入值