var Marquee = function(j,s,w) {
var self = this;
var jTarget = j;
var strText = s;
var intWidth = w;
var intPaddingLeft = 60;
var jText,intTextWidth;
var update = function() {
intPaddingLeft -= 2;
if (intPaddingLeft < -intTextWidth) {
intPaddingLeft += intTextWidth;
}
jText.css({'left':intPaddingLeft + 'px'});
};
var setup = function() {
jText = $('<div class="marquee-text"></div>').html(strText);
jTarget
.append(jText)
.append($('<div id="marquee-right"></div>').html(' '))
.append($('<div id="marquee-left"></div>').html(' '));
intTextWidth = $(jTarget).find('.marquee-text').width();
jTarget.width(intWidth);
jText.text(strText + " " + strText);
update();
};
setup();
setInterval(update,50);
return self;
};
strLoremIpsum = "12/14-17 - Sem. Exams • 12/20-1/3 - Winter Break • 1/4 - 4th Six Weeks Begins • ";
jQuery(function($) {
myMarquee = new Marquee($('div#marquee'),strLoremIpsum, 426);
});
I'm not that familiar with javascript but I'm trying to learn. The problem I'm having right now is that the string strLoremIpsum will only let me use text in it, if i put any html in it like "•" then it just types that out. How can I get html to work inside there?
Question
classicdisastr
I have this script that I'm using for a marquee
var Marquee = function(j,s,w) { var self = this; var jTarget = j; var strText = s; var intWidth = w; var intPaddingLeft = 60; var jText,intTextWidth; var update = function() { intPaddingLeft -= 2; if (intPaddingLeft < -intTextWidth) { intPaddingLeft += intTextWidth; } jText.css({'left':intPaddingLeft + 'px'}); }; var setup = function() { jText = $('<div class="marquee-text"></div>').html(strText); jTarget .append(jText) .append($('<div id="marquee-right"></div>').html(' ')) .append($('<div id="marquee-left"></div>').html(' ')); intTextWidth = $(jTarget).find('.marquee-text').width(); jTarget.width(intWidth); jText.text(strText + " " + strText); update(); }; setup(); setInterval(update,50); return self; }; strLoremIpsum = "12/14-17 - Sem. Exams • 12/20-1/3 - Winter Break • 1/4 - 4th Six Weeks Begins • "; jQuery(function($) { myMarquee = new Marquee($('div#marquee'),strLoremIpsum, 426); });I'm not that familiar with javascript but I'm trying to learn. The problem I'm having right now is that the string strLoremIpsum will only let me use text in it, if i put any html in it like "•" then it just types that out. How can I get html to work inside there?
Link to comment
Share on other sites
1 answer to this question
Recommended Posts