JQuery simple operation
JQuery simple operation
I. Introduction
I have been very white on the front-end. I only know some basic JS files, but I am not very familiar with jQuery. When I use jQuery, sometimes it is very easy to use. I also need to check the usage, learn the system, and record frequently used files. make a memo and take notes. Update constantly...
Ii. Common functions
1. $ ('# id'). remove () -- remove the element whose id is id.
2. $ ('# id'). empty () -- remove the content from the element whose id is id.
Iii. Utility plug-ins
1. Merge cells with the same content in the table:
A) content:
// A small JQuery plug-in encapsulated with jQuery code that combines cells with the same content. fn. rowspan = function (codecomx) {return this. each (function () {var that; $ ('tr ', this ). each (function (row) {$ ('td: eq ('+ codecomx +') ', this ). filter (': visible '). each (function (col) {if (that! = Null & lt; this).html () = condition (that).html () {rowspan = $ (that ). attr (rowSpan); if (rowspan = undefined) {$ (that ). attr (rowSpan, 1); rowspan = $ (that ). attr (rowSpan);} rowspan = Number (rowspan) + 1; $ (that ). attr (rowSpan, rowspan); $ (this ). hide () ;}else {that = this ;}});});});}
B) Test content: dynamically generate data tables, pages, and js:
| Project name |
Monitoring type |
Sub-project name |
Log Information |
Function init () {// obtain the dataset result... // construct the table: for (var I in result) {fillShowLogTable (result [I]);} // specify the rows of the table to be merged $ ('# logDetailTable '). rowspan (0); $ ('# logDetailTable '). rowspan (1);} function fillShowLogTable (list) {var str = ''; str + ='' + list. PRO_TITLE + ''; str + ='' + list. SUB_PROJECT_NAME + ''; str + ='' + list. TASK_NAME + ''; if (list. TIP_VALUE = 'no') {list. TIP_VALUE = 'no new log'; str + = ''+ list. TIP_VALUE + '';} else if (list. TIP_VALUE = 'yes') {list. TIP_VALUE = 'new log'; str + = ''+ list. TIP_VALUE + '';} $ (str ). appendTo ($ ('# logDetailInfo '));}
C) test results: