jquery Simple operation

Source: Internet
Author: User

jquery Simple operation
A: Introduction

In front of the side has been very small white, only to understand some basic JS, is not too familiar with, jquery is also, use sometimes very simple usage also to check, the system of learning, the commonly used records to do a memo, but also notes. Constantly updated ...

Two: Common functions

1, $ (' #id '). Remove ()--Removes the element with ID ID.

2, $ (' #id '). Empty ()--Removes the contents of an element with ID ID.

Three: Utility Plug-in

1. Cells that merge the same content in the table:

A) content:

Encapsulates a jquery widget that implements the same content merged cell code jQuery.fn.rowspan = function (colidx) {return This.each (function () {var that;$ (' tr '), This). each (the function (row) {$ (' td:eq (' + colidx + ') ', this). The filter (': Visible '). each (the function (col) {if (That! = null&& Amp $ (this). the html () = = $ (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 generated data table, page and JS:

<body onload= "init ();" ><div align= "center" ><table id= "logdetailtable" width= "99%" border= "1" collapse= "collapse" ><thead ><tr><th width= "20%" height= "40px" > Project name </th><th width= "20%" height= "40px" > Monitoring type </th ><th width= "35%" height= "40px" > Sub-project name </th><th width= "25%" height= "40px" > Log information </th></tr ></thead><tbody id= "Logdetailinfo" ></TBODY></TABLE></DIV></BODY> 
function init () {//Get DataSet result...//build Table:for (var i in result) {fillshowlogtable (result[i]);} Specifies the rows (' #logDetailTable ') of the table to be merged. rowspan (0); $ (' #logDetailTable '). rowspan (1);} function fillshowlogtable (list) {var str = '; str + = ' <tr><td style= ' width:20%;text-align:center ' > ' +list. Pro_title+ ' </td> '; str + = ' <td style= "Width:20%;height:30px;text-align:center" > "+list. sub_project_name+ ' </td> '; str + = ' <td style= "Width:35%;height:30px;text-align:center" > "+list. task_name+ ' </td> '; if (list. Tip_value = = ' no ') {list. Tip_value = ' no new log '; str + = ' <td class= "Nonewlog" style= "Width:25%;height:30px;text-align:center" > ' +list. Tip_value+ ' </td></tr> ';} else if (list. Tip_value = = ' yes ') {list. Tip_value = ' new log '; str + = ' <td class= "Hasnewlog" style= "Width:25%;height:30px;text-align:center" > ' +list. Tip_value+ ' </td></tr> ';} $ (str). AppendTo ($ (' #logDetailInfo '));}


c) Test results:


Summarize:

Apply. Practice is the quickest shortcut!


jquery Simple operation

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.