Front-end pen exam notes: enables sorting of table headers in ascending/descending order in HTML

Source: Internet
Author: User

Front-end pen exam notes: enables sorting of table headers in ascending/descending order in HTML
Question: for example, please sort table information. When you click the attribute area of the header, you can switch the order of table information. That is, the first click is sort in descending order, click again to sort in ascending order.

Name Power Agility Intelligence
Druid 17 24 13
Monthly knight 15 22 16
King of the Gods 19 15 20
Stray swordsman 23 15 14
Basic Ideas: Created with Rapha? L 2.1.2 Click Store the values of each column into an array First click? (ClassName = ""?) Sort in ascending order (className = "desc ") Assign new values to each column in the order of newly arranged Arrays Sort in descending order (className = "") Yes No Complete code:
 
Name Power Agility Intelligence
Druid 17 24 13
Monthly knight 15 22 16
King of the Gods 19 15 20
Stray swordsman 23 15 14
<script type="text/javascript"> var tag=1; function sortNumberAS(a, b) { return a - b } function sortNumberDesc(a, b) { return b-a } function SortTable(obj){ var td0s=document.getElementsByName("td0"); var td1s=document.getElementsByName("td1"); var td2s=document.getElementsByName("td2"); var td3s=document.getElementsByName("td3"); var tdArray0=[]; var tdArray1=[]; var tdArray2=[]; var tdArray3=[]; for(var i=0;i

Related Article

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.