Jquery_1.7

1.jquery中用attr()方法来获取和设置元素属性.

 encodeURI(document.getElementById("TITLE").value) 传递中文名

2.

     $('.mainTable .mainTr').click(function(){
                 alert($(this).attr('id'));
      });

 

3. $("p").after("<b>Hello</b>"); 在每个匹配的元素之后插入内容

 

4.    鼠标悬停的表格加上特定的类

    $(".mainTableList tr").hover(
         function(){
               $(this).addClass("hover");
         },
       function(){
             $(this).removeClass("hover");  
      });

5.  为每个匹配元素的特定事件绑定事件处理函数。

function handler(event){
       alert(event.data.foo);
      }
$('#p01').bind("click",{foo:"bar"},handler);

 

6. 该方法就是将src合并到jquery的全局对象中去,如:就是将hello方法合并到jquery的全局对象中。

     $.extend({
               hello:function(){alert("hello");}
      });

7.$("body").append("<table><tr><td>Toeoe</td></tr></table>");

8.从所有的段落开始,进一步搜索下面的span元素。与$("p span")相同

$("div").find("span").text();

9.

$(function(){
jQuery("#subId option[value='04']").remove();   
});

10.

<input type="radio" id="radio1" name="houseType" checked="checked" value="2">新盘

<input type="radio" id="radio1" name="houseType" value="1">二手盘


1.获取单选框选中的值

$('input[name=houseType]:checked').val()


2.通过单选框的值选择相应的单选框

$("input[name=houseType]").val([2]);

$(":radio[name='houseType'][value=2]").attr("checked",true);


3.指定id选中

$("#radio1").prop("checked",true);


4.取消选中

$("#radio1").prop("checked",false);

$(":radio[name='houseType']").removeAttr("checked");

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值