JS achieves the commonly used scoring results for websites!

Source: Internet
Author: User
View code

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> special website scoring effect </title>
<Style type = "text/CSS">
*
{
Font-size: 50px;
}
</Style>
<Script language = "JavaScript" type = "text/JavaScript">
Function indexof (ARR, element) {// write the indexof method in Js;
For (VAR I = 0; I <arr. length; I ++ ){
If (ARR [I] = element ){
Return I;
}
}
Return-1;
}

Function commentlevel (){
VaR commentlevel = Document. getelementbyid ("commentlevel ");
VaR TDS = Document. getelementsbytagname ("TD"); // obtain the TD in the commentlevel table. The TD in other tables is not processed;
For (VAR I = 0; I <TDs. length; I ++ ){
VaR TD = TDS [I]; // obtain each TD;
TD. onmouseover = tdonclick;
TD. style. cursor = "Pointer ";
}
}

Function tdonclick (){
VaR commentlevel = Document. getelementbyid ("commentlevel ");
VaR TDS = Document. getelementsbytagname ("TD"); // obtain the TD in the commentlevel table. The TD in other tables is not processed;
VaR Index = indexof (TDS, this); // obtain the current click position;

For (VAR I = 0; I <= index; I ++) {// The previous values are red;
TDS [I]. innertext ="★";
}

For (VAR I = index + 1; I <TDs. length; I ++) {// after clicking it, It is white;
TDS [I]. innertext = "☆ ";
}

}
</SCRIPT>
</Head>
<Body onload = "commentlevel ()">
<Table id = "commentlevel">
<Tr>
<TD>

</TD>
<TD>

</TD>
<TD>

</TD>
<TD>

</TD>
<TD>

</TD>
</Tr>
</Table>
</Body>
</Html>

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.