Home > front end >  Bosses help to look at the problem of how to write... A little super classes
Bosses help to look at the problem of how to write... A little super classes

Time:10-01

Client access to a json string, the string of the content presented on the page:
字符串内容为: Var str=甗{"age":19,"claNum":"WNCQJ032","counselor":"廖娟","dateOfBirth":"1992-10-10","education":"研究生","id":1,"name":"陈克金","schoolNum":"WNCQ201911023","sex":"男","telephone":"13908996789"},{"age":23,"claNum":"WNCQJ033","counselor":"覃玲","dateOfBirth":"1992-10-10","education":"本科生","id":2,"name":"陈浩","schoolNum":"WNCQ201911014","sex":"男","telephone":"13908996789"},{"age":15,"claNum":"WNCQJ032","counselor":"高羽","dateOfBirth":"1992-10-10","education":"研究生","id":3,"name":"徐瑞","schoolNum":"WNCQ201911057","sex":"女","telephone":"13908996789"},{"age":14,"claNum":"WNCQJ033","counselor":"张曼丽","dateOfBirth":"1992-10-10","education":"专科生","id":4,"name":"易恒","schoolNum":"WNCQ201911006","sex":"男","telephone":"13908996789"},{"age":20,"claNum":"WNCQJ034","counselor":"廖娟","dateOfBirth":"1992-10-10","education":"研究生","id":5,"name":"刘基航","schoolNum":"WNCQ201911014","sex":"女","telephone":"13908996789"},{"age":19,"claNum":"WNCQJ034","counselor":"高羽","dateOfBirth":"1992-10-10","education":"本科生","id":6,"name":"邓一凡","schoolNum":"WNCQ201911025","sex":"男","telephone":"13908996789"},{"age":27,"claNum":"WNCQJ032","counselor":"廖娟","dateOfBirth":"1992-10-10","education":"研究生","id":7,"name":"王渝怀","schoolNum":"WNCQ201911036","sex":"男","telephone":"13908996789"},{"age":21,"claNum":"WNCQJ032","counselor":"覃玲","dateOfBirth":"1992-10-10","education":"研究生","id":8,"name":"邹高兴","schoolNum":"WNCQ201911017","sex":"女","telephone":"13908996789"}]
";
Requirements are as follows: pay attention to the style of the interface, beautiful
: 1. The student information is added to the HTML page: with id number and name as the name, age to age, sex is sex, claNum for class number, schoolNum as student id, counselor to consulting teachers, telephone calls, dateOfBirth is birthday;
No. 2. The age, gender, class next to add click on the button, the button can be achieved to sort the contents of the table, such as button, click on the age, the information in the form according to the ascending order of age; As shown in the figure below:
3. The realization of each line is highlighted, the mouse moved to a row, the background color is grey

CodePudding user response:

1, 3, quite simply, 3 sorted with array sort
 
Var STR=[
{2, a: 0, b: c: 3},
{a: 1, b: 1, c: 3},
{8 a:, b: 7, c: 1}
]
//key sort field type sorting type 1 1 positive sequence in reverse chronological order
The function sortCell (key, type) {
If (type==='1') {
STR. Sort ((a, b)=& gt; {
[key] - a return b [key]
})
} else {
STR. Sort ((a, b)=& gt; {
Return a [key] - b [key]
})
}
The console. The log (STR)
}
SortCell (' b ', '1')


After sorting to regenerate the form
  • Related