I am a complete newbie with javascript and jquery. I've been trying to make this code work..
var links = [];
var innerlinks = [];
var count = document.getElementsByClassName("boss").length;
for (i = 0; i < count; i++) {
links[i] = 'http://something.com/'+ document.getElementsByClassName("boss")[i].firstChild.getAttribute("href");
};
for (j = 0; j < count; j++) {
$.get(links[j], function(data){
content=data;
});
var x = content.indexOf("<h5>Text");
var y = content.indexOf("someothertext", x);
var sliced=content.slice(x, y + 14);
var z = sliced.indexOf("href=");
var q = sliced.indexOf("style");
innerlinks[j]=sliced.slice(z + 6, q - 2);
};
alert(innerlinks);
..but it just doesn't seem to listen to me. I tried bunch of methods I read about here on stackoverflow but none seem to work. It's probably just some basic problem I have no knowledge about yet.
What I want this script to do is basically take the link, receive it's content, take a portion of it (a link) and store it into an array. Then move to another one.
While this one just takes a random link from the links array and fills the innerlinks array with same value. I do suspect content variable here, but I can't come up with any solution. Any and all help would be really appreciated!