4

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 = align is not working.

Where am I going wrong?

1
  • 1
    I've edited your tags to include JQuery and edited your question to improve its quality. Please feel free to refine my edits if any are in error. In the future, please be a little more specific, it will help you get great answers faster. Commented Feb 25, 2011 at 11:20

5 Answers 5

10

it seems you're using jQuery, so you can do something like :

column.attr('align', 'right');
Sign up to request clarification or add additional context in comments.

Comments

2

Try this one:

$(column).attr("align","left");

Comments

0

Looks like you're using jQuery? Use column.attr('align', 'whatev') or better yet, use CSS.

Comments

0

Judging from the $ selector, you are using jQuery.

In that case, column is not a DOM element, but a jQuery selector result, and you have to treat it accordingly:

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.