js (jQuery) 之 取值

取值笔记

          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();

         6:子界面控制父页面跳转:

                      window.parent.location.href = “*” ;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容