下面這段代碼執行以後,為什麼border變成了11,不是2?如果想達到2的效果應該怎麼寫?
<script>
function displayResult()
{
document.getElementById("p1").style.cssText="border:"+1+1+"px dashed green;color:red";
}
</script>
<p id="p1" style="border:1px dashed green;color:red;">This is a paragraph.</p>
<br>
<button type="button" onclick="displayResult()">Get the style declaration as a string</button>
document.getElementById("p1").style.cssText="border:"+(1+1)+"px dashed green;color:red";