Solved

jQuery - get text inside span to align left

Posted on 2013-01-24
2
534 Views
Last Modified: 2013-01-24
Using jQuery - how do I get the text inside of a span to align left?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
soupBoy earned 500 total points
ID: 38815867
By default, spans are inline elements and should be aligning left.  

Are you trying to override a css rule?
This could be done easily by css, all JQuery would be doing would be injected css inline...

//using JQuery to build your css
$('.targetSpan').css({
  display: 'inline-block',
  textAlign: 'left'
});

Open in new window


/*it is better to do it like this*/
.targetSpan{
  display: inline-block;
  text-align: left;
}

Open in new window

0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 38815892
I went with:

 $('span[id*="lblDetails"]').css('text-align', 'left');

Maybe not best practice, but more fun with jQuery.  : )
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery Bold 3 specific words in a paragraph 5 39
disable open new tab with right mouse click in <a> tag 3 41
sort Multi-dimensional array 6 44
bootstrap collapse 2 17
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question