jQuery学习实用记录

//jQuery加载
$(document).ready(function(){
  //开始编写函数
});






//点击后 上下滑动隐藏效果
$("#id").click(function(){
  $("id2").sildeToggle(); });
//创建自定义动画,可以实用队列功能(编写多个animate逐一调用)
$("button").click(function(){ $("div").animate({left:'250px'}); });

//停止动画或效果,在它们完成之前
//stop() 方法适用于所有 jQuery 效果函数,包括滑动、淡入淡出和自定义动画
$("clickBottonID").click(function(){ $("#stopID").stop(); });
//设置或返回所选元素的文本内容
$("#btn1").click(function(){ alert("Text: " + $("#test").text()); });

//设置或返回所选元素的内容(包括 HTML 标记) $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); });

//设置或返回表单字段的值
$("#btn1").click(function(){ alert("Value: " + $("#test").val()); });

//attr() 方法用于获取属性值
$("button").click(function(){ alert($("#w3s").attr("href")); });

//append() 方法在被选元素的结尾插入内容
$("p").append("Some appended text.");



//prepend() 方法在被选元素的开头插入内容
$("p").prepend("Some prepended text.");


//jQuery after() 方法在被选元素之后插入内容
$("img").after("Some text after");
//jQuery before() 方法在被选元素之前插入内容
$("img").before("Some text before");


 

posted on 2013-11-05 22:47  吴翰哲  阅读(179)  评论(0编辑  收藏  举报

导航