如果有兩個按鈕,按下後都會執行同一個函式,請問要如何知道是哪個按鈕按下的?
我底下寫的這個是錯的,不知道如何修改,不知道document有沒有getSource之類的函式,可以判斷是哪個來源
謝謝你
<form name="MyF">
<input type="button" name="btn1" id="btn1" onClick="process()" value="按鈕一">
<input type="button" name="btn2" id="btn2" onClick="process()" value="按鈕二">
</form>
<script>
function process()
{
n=document.getElementById("btn1");
document.write("你按下的是"+n.value);
n=document.getElementById("btn2");
document.write("你按下的是"+n.value);
}
</script>