jQuery 学笔记,jQuery的第一个例子

这是jQuery的第一个例子。

代码只是页面中的一段。       

CSS类代码如下:新建一CSS样式类,类名为sss

1 <style type="text/css">
2 .sss {
3 background:#3CF
4 }
5 </style>

JavaScript脚本:

第6行:出一对话框。

第8行:选择tabel 的偶数tr,并添加sss类。

 1 <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
2
3 <script type="text/javascript">
4 $(document).ready(
5 function(){
6 alert("aaaaa");
7 $("<p>aaaaaaaaaa</p>").insertAfter("#folloMe");
8 $("table tr:nth-child(even)").addClass("sss");
9 }
10 )
11 </script>
1 $("p#folloMe").click(
2 function(){alert("cccccc");}
3 );

如要选中id=folloMe的P元素,如上。注意,中间没有空格。

  

      

原文地址:https://www.cnblogs.com/xyzabc0004/p/2424546.html