How to dynamically set alignment property for td in javascript?

Here is my code, my question is in the comment:

function (align) {    
    var column = $(`'<td>'`);  
  // now i need syntax to set align property to this td element  
  // column.align = align (not working)  
}

As shown, column.align = aligndoes not work.

Where am I going wrong?

+3
source share
5 answers

You seem to be using jQuery, so you can do something like:

column.attr('align', 'right');
+7
source

Try the following:

$(column).attr("align","left");
+1
source

, jQuery? column.attr('align', 'whatev') , CSS.

0

$, jQuery.

column DOM, jQuery, :

$(column).attr('align', 'left');
0

, myTD.setAttribute( "align", "right" );

0

Source: https://habr.com/ru/post/1794683/


All Articles