Hi,
I want to access availJobs in jobs.scan object but I couldn't. It is not defined in jobs.attack. What can I do to access the part of jobs.scan in other objects?
var jobs = new Array();
jobs.scan = function() {
var availJobs = new Array();
var jobContents = dom.get("app8743457343_content");
var boldthreads = jobContents.getElementsByTagName('b');
for(var i = 0; i < boldthreads.length; i++) {
if(boldthreads[i].style.color == 'silver') {
availJobs.push(boldthreads[i].textContent);
}
}
return availJobs;
}
jobs.attack = function() {
jobs.scan();
alert(jobs.availJobs[0]);
}
jobs.attack();
availJobs[0] in jobs.attack doesn't work. It's undefined. How can I set the availJobs as public and can be accessed in other objects?jav
Thanks for all the help!! Here's the code that I put:
var jobs = {
availJobs: new Array(),
scan: function() {
var jobContents = dom.get("app8743457343_content");
var boldthreads = jobContents.getElementsByTagName('b');
for(var i = 0; i < boldthreads.length; i++) {
if(boldthreads[i].style.color == 'silver') {
this.availJobs.push(boldthreads[i].textContent);
}
}
},
attack: function() {
this.scan();
alert(this.availJobs[0]);
},
};
jobs.attack();
This code is definitely more elegant don't you think? I used this and it worked!