Click here to Skip to main content
16,021,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone give me an example of how to add a nowrap to
tag of table via Jquery???
Posted

JavaScript
$("#idOfItem").attr('noWarp','noWrap');
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 19-Mar-12 17:49pm    
Correct, my 5. However, 'nowrap' is deprecated in XHTML. CSS should be used.
--SA
Sergey Alexandrovich Kryukov 19-Mar-12 17:54pm    
So, I provided a better non-deprecated answer. Please see.
--SA
As I say, "nowrap" attribute is obsolete. You are strongly advised to use CSS instead:
CSS
p
{
white-space:nowrap;
}
/* or */
.nowrap
{
white-space:nowrap;
}

Please see: http://www.w3schools.com/cssref/pr_text_white-space.asp[^].

In jQuery:
JavaScript
$("#idOfItem").css('white-space','nowrap');

Please see:
http://api.jquery.com/css/[^].

Or, better yet:
JavaScript
$("#idOfItem").addClass("nowrap"); //see the class in CSS sample above


Please see:
http://api.jquery.com/addClass/[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900