Solved

jQuery - get text inside span to align left

Posted on 2013-01-24
2
528 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:knowlton
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: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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now