I have this Object:
Object ->
Content: <h1>some html</h1>
Url : A url
Now i’m using this code to work out if a certain URL exists in the current object:
var inURLArray = function(url, array) {
for(var i in array) {
if(array[i].url && array[i].url == url)
return true;
}
return false;
};
So i pass it the url i’m looking for and the object i’m looking in. I can then do var found = inURLArray('http://google.com', tabArray); what could i do if i find the URL i’m looking for to get the content in the same Object. The array is called tabArray. I’m using jQuery/Javascript!
I should say, i dont really mind how i access the content, ie. if its stored in a variable or alerted!
You could replace the boolean function by one that simply returns the object found, or null if there isn’t one: