jQuery - get text inside span to align left

Using jQuery - how do I get the text inside of a span to align left?
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
soupBoyConnect With a Mentor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
I went with:

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

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

From novice to tech pro — start learning today.