尝试使用vanilla js将用户输入的字符串追加到锚点标记href。将输入字符串附加到锚点标记href
<script>
function searchProduct(){
var inputId = document.getElementById('inputId').value;
document.getElementById('go').href = "mywebsite/product/" + inputId;
}
searchProduct();
</script>
<a id="go"><p>Go</p></a>
然而,这是不正常
你在哪里触发功能? – 2015-02-09 20:43:40
请显示锚标记的html – fnostro 2015-02-09 20:43:44
@fnostro编辑 – softcode 2015-02-09 20:46:02