Home > front end >  To solve, why didn't toggleClass cannot effect
To solve, why didn't toggleClass cannot effect

Time:09-27

 
. Select the row - {
Background - color: # 4 eb305;
color: #fff;
}




Selection & lt; Input type='checkbox' id="allChecked & gt;"
The serial number & lt;/th>
Name & lt;/th>
The type & lt;/th>
Unified coding & lt;/th>
Code & lt;/th>
Affiliation & lt;/th>
Founder & lt;/th>
Creation date & lt;/th>
Revised one & lt;/th>
The revision date & lt;/th>








<script>
$(' # orgTable tbody ') on (' click ', 'tr', function () {
$(this). ToggleClass (' select - row);
Var checkboxs=$(this). The find (" input: the checkbox ");
If ($(this). HasClass (" select - row ")) {
$(checkboxs [0]). Prop (" checked ", true);
} else {
$(checkboxs [0]). Prop (" checked ", false);
}
});

$(" # allChecked "). Change (function (e) {
//to determine whether a state is selected
If ($(e.c. with our fabrication: urrentTarget). Prop (" checked ")) {
$(' # orgTable tbody tr input: the checkbox '), prop (" checked ", true);
$(' # orgTable tbody tr '). The addClass (" select - row ");
} else {
$(' # orgTable tbody tr input: the checkbox '), prop (" checked ", false);
$(' # orgTable tbody tr '). RemoveClass (" select - row ");
}
});
<script>




ToggleClass why doesn't work here, and how to modify is white white

CodePudding user response:

Table from the database query dynamically generated content, click the check box, how to choose is white white, solving

CodePudding user response:

Check & lt; tbody> The tag format right, isn't it & lt; tr> Nested & lt; td>

CodePudding user response:

Didn't write anything at the beginning, just tried it on, it is of little use if

CodePudding user response:

Didn't write anything at the beginning, just tried it on, as if it's no use

CodePudding user response:

refer to the second floor baiy20151018b response:
check & lt; tbody> The tag format right, isn't it & lt; tr> Nested & lt; td>

Didn't write anything at the beginning, just tried it on, as if it's no use

CodePudding user response:

reference 5 floor qq_40572452 reply:
Quote: refer to the second floor baiy20151018b response:
check & lt; tbody> The tag format right, isn't it & lt; tr> Nested & lt; td>

Didn't write anything at the beginning, just tried it on, it is of little use if

If there is no data?

CodePudding user response:

refer to 6th floor baiy20151018b response:
Quote: refer to the fifth floor qq_40572452 reply:

Quote: refer to the second floor baiy20151018b response:
check & lt; tbody> The tag format right, isn't it & lt; tr> Nested & lt; td>

Didn't write anything at the beginning, just tried it on, it is of little use if

If there is no data?

Yes, only the label,

CodePudding user response:


Because the selector is when click # orgTable tbody will trigger events, no content in the tbody, events will not be triggered,

CodePudding user response:

Js code is no problem, just you & lt;/script> Less/

CodePudding user response:

references 9/f, the sky wave response:
js code is no problem, just you & lt;/script> Less/

No, it's in the js script written page, here is to separate,

CodePudding user response:

refer to the eighth floor baiy20151018b response:

Because the selector is when click # orgTable tbody will trigger events, no content in the tbody, events will not be triggered,

How to break? The content in the tbody cannot complete from the database to check the inside of the content

CodePudding user response:

Now is tbody no content, of course, no effect, you add some data in the database, let tbody in at least one row, can have,

CodePudding user response:

11 references qq_40572452 response:
Quote: refer to the eighth floor baiy20151018b response:

Because the selector is when click # orgTable tbody will trigger events, no content in the tbody, events will not be triggered,

How to break? The tbody cannot complete the content from the database to check the inside of the content

Data from the database to check, should fill in the td, under the tbody tr will click,
The most visually, page should be able to see the data found in the database,

CodePudding user response:


You change the tbody to thead try

CodePudding user response:

Jq under version 1.8
  • Related