都是一些老生常談,沒什麼新東西,算是開發過程當中不知道怎麼寫去百度的一些東西 。都說程序員寫博客是一個好習慣,算是一份保存筆記,之後不用處處百度而後出來的一些答非所問的答案 。html
1: 根據class 、 id 取 input 標籤的value 值 。
jQuery : $(".className").val(); $("#idName").val();
javaScript : document.getElementById("idName").value;
2: 根據class 、id 獲取標籤之間的內容:如 <span> 、<lable> 、<div> 。
jQuery : $("#idName").html(); $(".className").html();
javaScript : document.getElementById("idName").innerHTML ;
3: 獲取<select id='selectId'> <option value='selectValue'> 選中值:
jQuery : $("#selectId").val();
javaScript : document.getElementById("selectId").value;
4: 獲取<img > 的 src 內容 :
jQuery : $("#imgId")[0].src;
javaScript : document.getElementById("imgId").src;
5:子界面獲取父界面元素內容:
5.1 (標籤間的內容 ,如 <span> 、<lable> 、<div> )
JavaScript : window.parent.document.getElementById("currentPage").innerHTML ;
JQuery : $(window.parent.document).find("#IdName").text();
5.2 (取 input 標籤的value 值)
JavaScript : window.parent.document.getElementById("currentPage").value ;
JQuery : $(window.parent.document).find("#IdName").val();java
6:子界面控制父頁面跳轉:程序員
window.parent.location.href = 「*」 ;spa