JavaScript "call" method use

Using "call" method to overwrite what "this" equals inside of an externally invoked function, called using jQuery animate...

by lasha

HTML

<div class="cellcontent">FFUUUUUUUUUUUUUU!</div>

CSS

.cellcontent{
    width: 300px;
    height: 200px;
    background-color: #F024EE;
    position: relative;
    margin: 0 auto;    
}

JavaScript

var onComplete = function (hello, goodbye) {
     console.log("from ext func def: " + $(this).width());
     alert(hello + " " + goodbye);
     this.css("border","3px solid #999")
         .animate({ left: '+=190'},{duration: 10000});
     console.log($(this).width());
};

$('.cellcontent').animate({
    left: '-=190'}, {
    duration: 1000,
        complete: function() {
            onComplete.call($(this), "hello!", "goodbye!");         
        } 
 });