This is my lame first attempt. I would like to get a count of every unique word in a table. Based on that count, I would like to change the size of the text. I’ve tried to do this by adding a different class to every column on a table (so the first cell in the column of a table has a ‘first’ class, and the second cell in a table has a ‘second’ class in every column. I’m trying to do this programatically so I don’t have to brute force a regex for every word that might populate the table. Any steerage in the right direction will be great 🙂
JS
$(function()
{
var searchTerms = $('.thetable').text(); //get all search terms in table
var words[] = text.split(''); //make them into an array
for(var count =0, count < words.length; count++)
{
$('#results').append(words[i]);
}
if($('.first').length > 1).css({'font-size': 13 + 'px'}))
else if($'.second').length > 1 && < 3).css({'font-size': 16 + 'px'}))
else($('.third').length > 3).css({'font-size':18 + 'px'))
}
});
HTML
<body>
<div id="results"></div>
<table style="width: 35%" cellspacing="1" class="thetable">
<tr >
<td class="first">one</td>
<td class="second">three</td>
<td class="third">five </td>
<td class="fourth">six</td>
<td class="fifth">ten</td>
</tr>
<tr>
<td class="first">one</td>
<td class="second">three</td>
<td class="third">five</td>
<td class="fourth">seven</td>
<td class="fifth">ten</td>
</tr>
<tr>
<td class="first">one</td>
<td class="second">four</td>
<td class="third">five</td>
<td class="fourth">eight</td>
<td class="fifth">ten</td>
</tr>
<tr>
<td class="first">two</td>
<td class="second">four</td>
<td class="third">five</td>
<td class="fourth">nine</td>
<td class="fifth">ten</td>
</tr>
</table>
</body>
demo: http://jsfiddle.net/XRpzp/1/