unemployment Posted June 20, 2011 Share Posted June 20, 2011 Why doesn't my console.log work? It's causing a firebug error which I can't see because upon enter the page is reloaded. if (search_list_ele_array[j].className== 'user list_hover'){ var link = search_list_ele_array[j].getElementsByTagName('a'); console.log(link.href); } Quote Link to comment https://forums.phpfreaks.com/topic/239901-cant-take-the-href-of-a-link/ Share on other sites More sharing options...
KevinM1 Posted June 20, 2011 Share Posted June 20, 2011 getElementsByTagName returns an array of elements. Arrays don't have a href property. You need to access an individual element by supplying an index, like: console.log(link[0].href); // logs the href of the first element in the array Quote Link to comment https://forums.phpfreaks.com/topic/239901-cant-take-the-href-of-a-link/#findComment-1232288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.