Jquery part of PHP Test

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.