<input type="button" value="父節點"onclick="change(curTarget.parentNode);" /><input type="button" value="第一個"onclick="change(curTarget.parentNode.firstChild.nextSibling);" /><input type="button" value="上一個"onclick="change(curTarget.previousSibling.previousSibling);" /><input type="button" value="下一個"onclick="change(curTarget.nextSibling.nextSibling);" /><input type="button" value="最后一個"onclick="change(curTarget.parentNode.lastChild.previousSibling);" />
獲取表單元素
<form id="d" action="" method="get"><input name="user" type="text" /> <br /><input name="pass" type="text" /> <br /><select name="color"><option value="red">紅色</option><option value="blue">藍色</option></select> <br /><input type="button" value="第一個" onclick="alert(document.getElementById('d').elements[0].value);" /><input type="button" value="第二個" onclick="alert(document.getElementById('d').elements['pass'].value);" /><input type="button" value="第三個" onclick="alert(document.getElementById('d').color.value);" /></form>