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");
jQuery实战技巧

1358

被折叠的 条评论
为什么被折叠?



