Delphinidin

Get any informations you need in depth explanation

- Adding a Row After a Row Based on Its Index Value
Just as you add a row based on its position in the table as first or last, you can also insert a row based on the index value of the row proceeding or following it. Set up a selector that selects all elements that have an index of 5 using the :eq() filter and insert the Special Offer TODAY HTML content directly after the matched element.

$("tr:eq(5)").after('<tr><td colspan="4">Special Offer TODAY</td></tr>');

- Adding a Message After Rows With Specific Content
If you would like to insert rows into a table before or after a text string contained in the table rows, you can do so by using the :contains filter. Consider this scenario: You would like to match all rows (Clothing) and add a special message after each row that contains this string. The message contains HTML that mentions a special offer. It's a clever way to call out specifi c elements and highlight them within the DOM. It's important to note that the contains filter is case-sensitive. If it came across any strings in a lowercase, if you had specifi ed uppercase, they would be skipped over. Create a selector statement using the tr elements on the page. Using the :contains filter, you can match all table rows that contain the string Clothing. After each matched set, insert a Special Offer
table row.

$('tr:contains("Clothing")').after('<tr><td colspan="4" class="special">Special
Offer TODAY</td></tr>');

- Removing a Row Based on Its Content
Just as you can add a row based on specifi c content, you can also remove elements based on the content contained within them. Set up a selector statement that selects all tr elements that have contain the string Clothing and removes them from the DOM.

$("tr").remove(":contains('Clothing')");

Read Again:
How to Manipulating The Data in Tables with jQuery - Part 1

0 comments:

Post a Comment

Site Info