function url_info()
{
var url_val=document.getElementsByClassName("spc-tab");
var current_s=0;
for(var i=0;i<url_val.length;i++)
{
var url_class=url_val[i].className.split(" ");
if(url_class[1]!=null)
{
if(url_class[1]=="selected")
{
current_s=i;
break;
}
}
}
var temp_1=url_val[current_s].text; //**Error here**
return(temp_1);
}
In this function url_info i am getting the TypeError But i don't know why?? .... as My var current_s is defined within the scope and integer...
HTML Collectiontextproperty is supposed to be though!document.querySelector(".spc-tab.selected").textContent;.document.getElementsByClassName("spc-tab")is returning an empty HTMLCollection ... which is why you get the error ... you're probably callingurl_infobefore any elements with that class exist - which is a common error, trying to run javascript before the page loads