This afternoon, I took the PHP test for the first time. The question was not difficult. Maybe I was a little nervous. In addition, I did not write code for a long time. I was wrong ....
1. <SCRIPT type = "application/JavaScript" src = "secondtrade/public/JS/publicjs/jquery1.7.js"> </SCRIPT>
<Style type = "text/CSS">
<Ul>
<Li> aaaaaa </LI>
<Li class = "cc"> bbbbbb </LI>
<Li class = "cc"> cccccc </LI>
<Li> dddddd </LI>
<Li class = "cc"> ffffff </LI>
</Ul>
Problem: Set the Li font of class to "cc" to red.
Calculate the number of lies whose class is "cc" in ul.
. Change {
Color: red;
}
</Style>
<Script language = "JavaScript">
$ (Document). Ready (function (){
// Method 1
$ (". Cc" ).css ("color", "Red ");
// Method 2
$ (". Cc"). addclass ("change ");
// Second question
VaR arr = $ ("Ul Li. cc ");
VaR n = arr. length;
Alert (n); // array Length
});
</SCRIPT>
2. Write the function of. Each (), write the difference between window. onload () and document. Ready (), and write the difference between empty () and remove ().
Each: It can traverse one-dimensional arrays, multi-dimensional arrays, Dom, JSON, and so on.
$ (Document ). ready () is executed after the DOM structure is loaded, while window. onload is executed after all files are loaded. Note the difference: one is that the Dom is loaded, and the other is that all files are loaded.
After the Dom is loaded, the DOM model is loaded, that is, the code is loaded.
The biggest difference between the two is that after Dom is loaded, JavaScript code can be executed without waiting for the corresponding image to be loaded.
Empty: This method not only deletes its subnodes, but also deletes the text fields of the node (according to Dom specifications, the text fields of the node are also considered as subnodes ), reserve its position in the DOM
Remove: Same as empty, and also delete Dom location