MattsBits
MattsBits

MattsBits

Replace The Contents Of A Table Cell With JQuery  

by Matt Hawkins, 31/03/2011
Categories : JavaScript

The following jQuery script allows you to search for and replace the contents of a table cell with some other content. This can be used to dynamically format your table data.

It's quite useful for colour coding text. In the example below I turn all PENDING text red.


<script>
$("td").filter(
  function(){
    return $(this).text() === "PENDING";}).
    text("<span style='background-color:red'>PENDING</span>");
</script>


In order to use this script to need to load the jQuery library from your html page. Please see the jQuery documentation for details on how to do this.

Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2017