Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add cellspacing="0" if it's not available for any `<table>` using jquery?

Tags:

jquery

css

xhtml

How to add cellspacing="0" if it's not available for any <table> using jquery?

and if it's available and it has any other value than ="0" then want to convert it to ="0"

like image 597
Jitendra Vyas Avatar asked Oct 22 '25 15:10

Jitendra Vyas


1 Answers

$('table').attr("cellspacing", 0);

Will change every table's cellspacing attribute to 0, whether it was previously defined or not.

Starting HTML:

<table> ... </table>
<table cellspacing="5" cellpadding="5"> ... </table>

Resulting HTML:

<table cellspacing="0"> ... </table>
<table cellspacing="0" cellpadding="5"> ... </table>
like image 102
Nilloc Avatar answered Oct 25 '25 06:10

Nilloc