Assume that I have an HTML table element, and there is a flexigrid corresponding to it. At the same time, the flexigird supports single choice and multiple choice is disabled. Now you need to add an event function so that it will be called when any row is clicked.
The ID of the element added to my table is subusers, and now the event function is defined. The Code is as follows:
Selectaccount: function () {// do something. Alert ('Hi :)');},
Register the above function to the click event:
$ ("# Subusers tbody TR"). Click (accounts. selectaccount );
Here we use jquery's method of searching for elements. We know that flexigird actually wraps the table, each table contains a tbody, and once it is Tr and TD,
This idea is to register accounts. selectaccount to all tr.
In this way, clicking any tr triggers the selectaccount function.
What? I don't know how to obtain the first column of the row in the event function. Jquery.
Sample Code:
Selectaccount: function () {// do nothing ());},
If you want to know whether there are any selected items, you can use the following code:
STR = $ (this). ATTR ("class"); If (Str. indexof ("trselected") =-1) {accounts. subuserid = NULL; return ;}
If-1 is returned, it is not selected.