Jquery sets the table style, jquerytable
In the previous article, we used jquery to achieve full selection of checkbox and got some suggestions from friends. I do not know the plug-in definition clearly, and I also made a joke, some of my friends suggested that I go to "sharp Jquery". To tell the truth, I am reading it
table id = "data" in HTMl, this parameter must be # data// Parameter description: _ w_table_rownum is the row of the cell to be merged. For the parameter format, see nth-child parameters in jQuery.// If it is a number, it starts from the first row 1 on the leftmost side.// "Even" indicates an even number of rows// "Od
today's implementation is an example of a table,by getting the odd rows of the table,Set Background color properties,makes the odd and even row background color different.This table can be edited when clicked,Enter to change to the newly entered content; ESCRestore the original text.the implementation of the
JQuery provides powerful functions for table processing, such as sorting specific rows or columns in a table, and changing the style. If your English is good enough, you can read this article: jQuery table manipulation. This article only describes how to use
Flexigrid is a lightweight jQuery table plug-in with a small size. The compressed JavaScript and css source code is less than 40 kb and is easy to use. However, simplicity usually means the lack of some advanced functions. Fortunately, its source code is relatively simple and easy to understand. The project homepage is: http: Flexigrid is a lightweight jQuery
Jquery implements statistics on the sum of cell values of specified columns in the table, jquerytable
Statistics implemented by jquery t] the sum of the cell values of the specified columns in the able table:In some applications, table cells store numbers, such as scores of students, which may be used as an addition op
How does jQuery obtain specified rows and columns of a table,
How does jQuery obtain the specified rows and columns of a table:When performing operations on heap tables, you often need to obtain the specified rows and columns, that is, you need to precisely locate them. This chapter briefly introduces how to implement this function.1. Get the specified row:Becau
JQuery provides powerful functions for table processing, such as sorting specific rows or columns in a table, and changing the style. If your English is good enough, you can read this article: jQuery table manipulation. This article only describes how to use
This example describes the super simple jquery action table method. Share to everyone for your reference. The implementation methods are as follows:
Use jquery to add a row to the specified table, delete a row
Copy Code cod
Here, jquery is used. Key
Code As follows:
Copy code The Code is as follows: // Add a data row;
Function addrow (){
VaR VTB = $ ("# tbdata"); // obtain the jquery object of table id = tbdata.
// All data rows have A. caserow class to get the size of the Data row
VaR vnum =
Here, we need to control user input verification, add and delete tables, statistical aggregation of user input data, and calculation columns such as total price of commodities = unit price of commodities * quantity of commodities, another example is that when a user submits a file, I also need to obtain the file submitted to the backend server and process it in the database. This plug-in simply handles these cumbersome tasks.
Description of plug-in attributes:
1: rowTemplate: This is the templat
Plug-in code;(function($) {$.fn.extend ({"Alterbgcolor":function(options) {Options=$.extend ({"Odd": "Odd",//the class of even rows"Even": "Even",//Odd Line Class"Selected": "Selected"//The row class is clicked},options);//the passed-in class parameter replaces the default class settingconsole.info (Options) $ ("Tbody tr:odd"). addclass (options.odd);//even line set class$ ("Tbody Tr:even"). addclass (Options.even);//Odd Line Set class$ ("tbody tr").
I found a table sorting on the Internet, but there is a problem in ascending and descending order, and the sorting time is incorrect. Therefore, I wrote a table sorting plug-in.
It can be sorted by any field. Because JavaScript sorting is used, it is refreshing and fast.
Default example:
$ (Function (){$ (". DataGrid"). sort ();});Example with parameters:
$ (Function (){$ (". DataGrid"). sort ({'Ascimgurl':
only needed to add the mouseup function to the body, but I didn't understand why the event was not triggered when the mouse was in th, so I had to add code to the th element. The level is limited. The following completely repeated code does not know how to extract it.
$ ("body "). BIND ("mouseup", function (event) {If (linemove = true) {$ ("# Line "). hide (); linemove = false; var Pos = currth. offset (); var Index = currth. prevall (). length;
example, if you want to remember where my house is, you need to know the street and house number. You only know that the first house in this street is my house. If someone else adds a new house here, that's not the first one (the analogy is a bit inappropriate, but the computer is so rigid ).
Therefore, we set an id for this tr and a class for QRUrl and LocalUrl. The Code is as follows:
In jQuery, you can find it like this:
The td tag is only found
1. $ ("# trid TD"). Text () returns a string for the value of TD in the trid.
2. $ ("# trid "). children obtains all TD information under a trid and then traverses $ ("# trid "). children use. eq (index ). text () to get the value in TD;
>
HtmlXmlns=Http://www.w3.org/1999/xhtml">
Head>
MetaHTTP-equiv="Content-Type"Content="Text/html; charset = gb2312"/>
Title>Untitled documentTitle>
ScriptLanguage="JavaScript"SRC=Jquery-1.6.2.min.js
:
Compile the JQUERY plug-in as follows:
Copy codeThe Code is as follows:; (function ($ ){
$. Fn. extend ({
"AlterBgColor": function (options ){
// Set the default value
Option = $. extend ({
Odd: "odd ",
Even: "even ",
Selected: "selected"
}, Options); // note that the option in the same options function (options) is the same object.
// Switch the color
$ ("Tbody> tr: enev", this). addClass (option. even );
$ ("Tbody> tr: odd", this). addClass (opti
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.