嘗試使用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