`
Michael.Jackson
  • 浏览: 13640 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

jquery学习随记

阅读更多

1. $("textarea[id='userTextArea']").html(); 获取textArea id='userTextArea'的html部分(即textarea的值)

 

2. 将某个页面元素隐藏:

<script type="text/javascript">


$(document).ready(function(){
  $("p").click(function(){
      alert ("I will hide !");
      $(this).hide();
  });
});
</script>


<body>
<p>If you click on me, I will disappear.</p>
</body>

3. 获取被选中的复选框productModelID属性值,并用“,”连接值

var productModelIDs  = "";

$("#productList_tb_body").find("input[name='ck']:checked").each( function() {
        productModelIDs = productModelIDs + $(this).attr("productModelID") + ",";
  });

4. 获取id='shareUserID'的输入框的值: $("input[id='shareUserID']").val();

5. 调用父页面的方法window.parent.functionName();

6. 在父页面调用当前子页面方法:clickEvent:function(){
            $("#jd_iframe")[0].contentWindow.functionName();
         }

7. 给某个html页面元素赋值:

   A. 将值赋给id="shareIDs"的页面元素: $("#shareIDs").val(value);

   B. 将输入框名称为 ck 的checked属性值置空 : $("input[name='ck']").attr("checked", "");

   C. 将输入框id为 ck 的checked属性值置空 : $("input[id='ck']").attr("checked", "");

8. form表单提交:$("#shareForm").submit();

9. 将id=‘get’的button失效:$("#get").attr("disabled", true);

 

 

10. jquery 获取id=pic容器内的img的src的值(img不加id或者class之类的指示应为是自动生成,不好改动,所以只好从容器id=pic获取img的src的值)

如下:

<div id=pic><img src=" http://www.baidu.com/" /></div>

获取完成之后写入以下

<div id=picsmll><img src="jquery 获取的src值"/></div>

参考:

 

var getsrc = $('#pic img').attr('src'); //获取值

$('#picsmll img').attr('src',getsrc); //设置值

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics