Q:如何添加jQuery库?
A:两种方式。
- <</SPAN>head>
-
<</SPAN>script type="text/javascript" src="jquery.js"></</SPAN>script> - </</SPAN>head>
- <</SPAN>head>
-
<</SPAN>script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></</SPAN>script> - </</SPAN>head>
-
- <</SPAN>head>
-
<</SPAN>script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></</SPAN>script> - </</SPAN>head>
Q:jQuery有哪些重要语法?
A:基础语法是:$(selector).action()
Q:(selector)选择器如何进行元素选择?
A:举例说明
- 的第一个
- 元素
$("[href]") 获取所有带有href属性的元素 $("[href$='.jpg']") 获取所有带有以 ".jpg" 结尾的属性值的 href 属性 $("div#test.test") 获取id="test" 的 元素中的所有 class="test" 的元素$("p").css("background-color","red") 将所有 段落 的背景颜色更改为红色