删除样式 $(“#myid”).removeClass(“myclass”)
加一个样式 $(“#myid”).css(“height”, “20px”)
加一组样式 $(“#myid”).css({height:”20px”, width:”100px”})
需要注意的是: 如果是加一个样式, 这个样式的名字是css中的名字, 比如说style=”background-color:#FF0000″, 对应的jQuery写法是 $(“#myid”).css(“background-color”, “#FF0000″)
但是加一组样式的时候, 样式的名字就是javascript中的css名字了, 比如: myid.style.backgroundColor = “#FF0000″, 对应的jQuery写法是 $(“#myid”).css({backgroundColor:”#FF0000″})
4. 根据关系查找元素
找和自己同级的下一个元素 $(“#myid”).next()
找和自己同级的所有位于自己之下的元素 $(“#myid”).nextAll()
找和自己同级的上一个元素 $(“#myid”).prev()
找和自己同级的所有位于自己之上的所有元素 $(“#myid”).prevAll()
找自己的第一代子元素 $(“#myid”).children()
找自己的第一个父元素 $(“#myid”).parent()
找自己的所有父元素 $(“#myid”).parents()
例子:
$("div.l4″).parents().each(
function() {
alert($(this).html());
});会把class=l4的div的所有父元素都得到, 并且alert出他们的html
例子:
$(“div.l4″).parents(“div.l2″).each(function() { alert($(this).html()); });
会得到class=l4的父元素, 该父元素必须是div, 而且其class=l2
这里说的所有方法, 都可以带表达式, 表达式的写法参考第一部分
5. 维护元素
在body中增加一个元素
$(“body”).append(“<input type=’text’ value=’asd’ />”)
该语句会把这段html插入到body结束标签之前, 结果是<input type=’text’ value=’asd’ /></body>
$(“body”).prepend(“<input type=’text’ value=’asd’ />”)
该语句会把这段html插入到body开始标签之后, 结果是<body><input type=’text’ value=’asd’ />
6.AJAX
用get方法请求一个页面
$.get(“http://www.google.com”, “q=jquery”, function(data, status){alert(data)})










