Hey there, I'm fairly new to JQuery and I am working on dynamically appending content to a div. I need to continuously scroll the content of that div to the top. After some research, I found a solution that meets my requirements.
Here's a snippet of my HTML, take a look:
<div class="news_container" id="NewsContent">
<div class="LatestNews">
<div class="Content">
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
Check out this example fiddler link here for reference
The code works perfectly in the fiddler above, but when implemented on an ASP.NET page, it throws an error stating:
"TypeError: jQuery.speed is not a function
optall = jQuery.speed( speed, easing, callback ),"
I'm puzzled by what could be wrong with the animate() function. Here's an excerpt of my code:
function CreateFunction() {
$.fn.loopScroll = function () {
var options = $.extend({
direction: "upwards",
speed: 50
});
var obj = $(this).find(".LatestNews");
var text_height = obj.find(".Content").height();
var start_y, end_y;
if (options.direction == "upwards") {
start_y = 0;
end_y = -text_height;
}
var animate = function () {
// setting up animation logic
var distance = Math.abs(end_y - parseInt(obj.css("top")));
obj.animate({top: end_y }, 1000 * distance / options.speed,
function () {
obj.css("top", start_y);
animate();
});
animate();
};
$("#NewsContent").loopScroll({ speed: 120 });
}
}
I'm having trouble understanding how optional parameters work. Can anyone suggest what might be causing the problem? Thanks in advance!