zoukankan      html  css  js  c++  java
  • 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();

  • 相关阅读:
    51nod1363-最小公倍数之和
    [模板] 数论题的一些经验
    WC2019游记 && 课件
    (伪)WC2019题解
    [模板] 后缀自动机&&后缀树
    [模板] 二分图博弈 && BZOJ2463:[中山市选2009]谁能赢呢?
    界面修改日志
    [模板] dp套dp && bzoj5336: [TJOI2018]party
    BZOJ1025:[SCOI2009]游戏
    [模板] BSGS/扩展BSGS
  • 原文地址:https://www.cnblogs.com/0914lx/p/7922213.html
Copyright © 2011-2022 走看看