如果我已經取得form元素,要如何取得底下的tag呢?
var x = document.getElementById("myForm").elements.length;
語法:
formObject.elements
如果我已經取得form元素,要如何取得底下的tag呢?
var x = document.getElementById("myForm").elements.length;
語法:
formObject.elements
在網頁中輸入特殊字符,需在html代碼中加入以&開頭的字母組合或以&#開頭的數字。例如,版權標誌符©即是用©或©表示。
常用符號“<”、">"、"&"、"空格"分別用“<”、“>”、“&”、“ ”表示,注意這些符號對大小寫是敏感的。
下面就是以字母或數字表示的特殊符號大全。
原來,要取得frame裡,頁面的元素,還要多一層寫法:
var ele = window.frames['frame_name'].document.getElementById('element_id');
參考:How can I get an element from within a frameset frame using JavaScript?
總結:
<a href="javascript: handler(); return false;">連結</a>
IE11 會對"return false;" 報錯...;還是先寫下面的好了...:
<a href="javascript:void(0)">連結</a>
1. 不能寫成 return(false);
2. 在 form tag 要加「return」。
<form action="index.jsp" method="post" onsubmit="return submitTest();">
form 表單,在送出前的事件。
window.onbeforeunload = confirmExit; function confirmExit() { return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?"; }