生活随笔
收集整理的這篇文章主要介紹了
jQuery学习--选择器的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
jQuery基本選擇器
- 1. jQuery的ready事件 -> js的onload
- 2. 選擇器的使用
1. jQuery的ready事件 -> js的onload
<script type
="text/javascript">$(function() {alert("hello jQuery!");});jQuery(function() {alert("load 2");});$(document
).ready(function() {alert("load 3");});jQuery(document
).ready(function() {alert("load 4"); });</script
>
2. 選擇器的使用
$(function() {$("#div1").css("background", "pink");$(".div2").css("background", "orange");$("div").css("background", "red");$("#div1, .div2").css("background", "yellow"); });
$("form input").css("background", "yellow");$("form > input").css("background", "red");$("label + input").css("background", "pink");$("form ~ input").css("background", "aqua");
$("#tab1 tr:odd").css("background", "aqua");alert($("#tab1 tr:eq(0)").html());
$("#divHello:has(p)").css("background", "blue");$("span[id]").css("background", "blue");$("input[name='newsletter']").prop("checked", true);
$(":button").click(function() {alert("hello,...");});
var val
= $("select option:selected").val();alert(val
);
jQuery中文文檔下載地址
更新…
總結
以上是生活随笔為你收集整理的jQuery学习--选择器的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。