Reputation: 5522
I've been editing a JQuery plugin 'airport' and have run into a problem;
I want the div to clear at the point mentioned in the code, but when I use $(self).empty(); the code just stops. (mid way down the code).
Here is my code:
function($){
$.fn.extend({
airport: function(array) {
var self = $(this);
var chars = ['a','b','c','d','e','f','g',' ','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','-'];
var longest = 0;
var items = items2 = array.length;
function pad(a,b) { return a + new Array(b - a.length + 1).join(' '); }
$(this).empty();
while(items--)
if(array[items].length > longest) longest = array[items].length;
spans = longest;
while(spans--)
$(this).prepend("<span class='c" + spans + "'></span>");
function testChar(a,b,c,d){
if(c >= array.length)
setTimeout(function() { testChar(0,0,0,0); }, 500);
else if(d >= array[c].length)
//Div should be cleared here...
setTimeout(function() { testChar(0,0,c+1,0); }, 500);
else {
$(self).find('.c'+a).html((chars[b]==" ")?" ":chars[b]);
setTimeout(function() {
if(b > chars.length)
testChar(a+1,0,c,d+1);
else if(chars[b] != array[c].substring(d,d+1).toLowerCase())
testChar(a,b+1,c,d);
else
testChar(a+1,0,c,d+1);
}, 20);
}
}
testChar(0,0,0,0);
}
});
})(jQuery);
Please tell me how to clear the div of all content. Thanks in advance!
Upvotes: -1
Views: 69
Reputation: 69905
self
is already a jQuery
object dont wrap it in $()
, then it should work fine.
Upvotes: 1