Jquery简单整理
2015-07-02 10:32
651 查看
开始会使用jquery cdn
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>或下载到本地引用。
使用$ jquery的标志 语法
$(this).hide() $("#test").hide()$("p").hide() $(".test").hide()
jquery的选择器
$("p.in") 选取class=“in”的p标签$("p").css("background-color","red")
jquery事件
如果您的网站包含许多页面,并且您希望您的 jQuery 函数易于维护,那么请把您的 jQuery 函数放到独立的 .js 文件中jQuery 使用 $ 符号作为 jQuery 的简介方式 某些其他
JavaScript 库中的函数(比如 Prototype)同样使用 $ 符号。 $ (解决 : $.noConflict(); )
$("button").click(function(){ })
$("#hide").click(function(){
$("p").hide();
});
jquery 获取
$("#btn1").click(function(){alert($("#test").text());
alert($("#test").val());
alert($("#test").attr("href")); // 获取href 属性
})
jquery设置
$("#btn1").click(function(){alert($("#test").text(”hello"));
alert($("#test").val("hello"));
alert($("#test").html("<b>hello<b>"));
alert($("#test").attr("href","www.baidu.com"));
})
jquery添加 append
$("p").prepend("Some prepended text."); 在开头插入
$("p").append("Some appended text."); 在尾部插入
jquery 操作css
正常是这样的.important { font-weight:bold; font-size:xx-large; } .blue { color:blue; }
使用$
$("button").click(function(){ $("h1,h2,p").addClass("blue"); $("div").addClass("important"); });
$(".blue").css("background-color","yellow");
相关文章推荐
- 『jQuery』.html(),.text()和.val()的使用
- jQuery选择器
- 深入学习理解jQuery中的extend方法以及JavaScript中对象的复制
- jquery获取所有选中的checkbox
- jquery返回顶部
- struts2+jquery+ajax的使用
- 10款基于jquery的web前端特效及源码下载
- jQuery切换所有复选框选中状态的方法
- jQuery移出style
- jQuery+toggle
- jQuery中的end()方法
- springMVC与jquery结合使用完整例子
- jquery遍历之children()与find()的区别
- jquery遍历table的tr获取td的值
- How to update jQuery Mobile in Dreamweaver CS6
- How to update jQuery Mobile in Dreamweaver CS6
- Jquery的个人学习笔记
- jquery国内cdn
- jQuery中间each实施例的方法
- JQuery使用的个人笔记