2013-10-19 37 views

回答

2

styleId="myLink"改爲<html:link>以便用JavaScript查詢元素。
然後您可以在JS中執行以下操作:

var val1 = "newval1", val2 = "newval2"; 

// Option 1: Set the href attribute regardless of its current value 
var link = document.getElementById("myLink"); 
link.setAttribute("href", "DemoAction.do?method="+val1+"&param1="+val2); 

// Option 2: Set the href attribute depending on its current value 
var link = document.getElementById("myLink"), 
    hrefParts = link.getAttribute("href").split("?"); 
link.setAttribute("href", hrefParts[0]+"?method="+val1+"&param1="+val2);