<script language="javascript"> var a,b,c,d;a=id;b=id;c=id;d=a+b+c; </script><div value="7" id="key_n7" class="bd f_l" onclick="alert(this.value)" onMouseOver="this.style.backgroundColor='#D4ECEE';" onMouseOut="this.style.backgroundColor='white'" style="cursor:pointer;">7</div><div value="8" id="key_n8" class="bd f_l" onclick="alert(this.value)" onMouseOver="this.style.backgroundColor='#D4ECEE';" onMouseOut="this.style.backgroundColor='white'" style="cursor:pointer;">8</div><div value="9" id="key_n9" class="bd f_l" onclick="alert(this.value)" onMouseOver="this.style.backgroundColor='#D4ECEE';" onMouseOut="this.style.backgroundColor='white'" style="cursor:pointer;">9</div><div value="+" id="key_na" class=" bd f_l" onclick="alert(this.value)" onMouseOver="this.style.backgroundColor='#D4ECEE'" onMouseOut="this.style.backgroundColor='white'" style="cursor:pointer;">+</div>在下新手刚刚接触JS,请问,上面的代码中,我怎么样才能,把7 8 9提取出来,存到变量a b c中,然后再提取'+',将7 8 9相加到一起.
2 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
var a = document.getElementById("key_n7").value;
var b = document.getElementById("key_n8").value;
var c = document.getElementById("key_n9").value;
var add = document.getElementById("key_na").value;
var d = a+add+b+add+c;
alert(d);
试试这样
添加回答
举报
0/150
提交
取消