Add border around table cell


Is there a way (javascript) which I can add border around the cell in the K2 design form.

 

I amd using this script, it add the border around the table but not to the cell

<script type="text/javascript">$(document).ready(function() {$("span[name='DepartmentValue']").closest('table').css({'border':'black 1px solid', 'background':'#56FFFF'});})</script>

 

Thanks,


3 replies

Badge +15

Hi,

 

Based on my html and jquery knowledge, you can try this:

 

<script type="text/javascript">$(document).ready(function() {$("span[name='DepartmentValue']").closest('table').find(tr td).css({'border':'black 1px solid', 'background':'#56FFFF'});})</script>

 

Table cells should be represented by <td>, so you just look for all <td> within a table and apply the css to it.

 

A quick tip. You can open your form in IE, Chrome, or FireFox, right-click on the table, and select "Inspect". It should allow you to view the underlying table structure. From there, it should be fairly easy to figure out how to use jquery style whatever you want.

Userlevel 3
Badge +5

I use this script to set the all borders and background of a table, something you can't do out the box.

 

The script appears in a literal data label placed inside the table. Put a label in the cell you want to modify and closest('td') might give you what you want.

 

<script type="text/javascript">$(document).ready(function() {$("span[name='TableCSS']").closest('table').css({'border':'gray 1px solid', 'background':'#EBECE5'}).find('td').css('border','lightgray 1px solid');})</script>

Thanks, The script is working 

 

<script type="text/javascript">$(document).ready(function() {$("span[name='ShortTitleLabel']").closest('table').css({'border':'black 1px solid', 'background':'#56FFFF'}).find('td').css('border','black 1px solid');})</script>

 

 

Reply