Page 1 of 1

How can I right code to css using javascript?

Posted: Thu Jan 30, 2014 1:46 am
by adam griffin

This is the code with in my html container :

div class = "ticker-container"
div class = "ticker-text"
Some text



and this the code for CSS:

.ticker_container {
width: 100%;
height: 2.9%;
border: 1px solid;
overflow: hidden;
}
.ticker-text {
height: 150%;
white-space:nowrap;
display:inline-block;
}

I would like to get the length of the text that is inputed into the html container. This is the code I have for javascript right now, but its not getting width.

var width = $('.ticker-text').width(),
containerwidth = Appery('ticker_container').width(),
left = containerwidth;


How can I right code to css using javascript?

Posted: Thu Jan 30, 2014 2:17 am
by Illya Stepanov

Hi -

Please clarify - do you want to get the text string length or do you want to get dimensions of a div element?


How can I right code to css using javascript?

Posted: Thu Jan 30, 2014 2:30 am
by adam griffin

I want to get the text string length. Sorry for the misunderstanding.


How can I right code to css using javascript?

Posted: Thu Jan 30, 2014 5:27 pm
by Kateryna Grynko

Hi Adam,

You can use this code:prevar len = $('.ticker-text').text().length;/pre


How can I right code to css using javascript?

Posted: Fri Jan 31, 2014 1:48 am
by adam griffin

It works!, But now I have the problem I cant get the text from the html to start from the right side of the container. It restarts the text flow at the left when I want it to go far left the restart from the right like a sports ticker


How can I right code to css using javascript?

Posted: Fri Jan 31, 2014 11:38 am
by Maryna Brodina

Hello! Sorry, i'm not sure I understand. Could you clarify what do you mean? Screenshots would help.