JQuery simple operation

Source: Internet
Author: User

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:

 

 

 

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.