joecool2005 Posted July 3, 2009 Share Posted July 3, 2009 Hi,Why my alert does not work on Firefox but it works on IE?Thanks for your help <html><head><script type="text/javascript">function getElements(){var x=document.getElementsByTagName("input");alert(x(0).name);}</script></head><body><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><br /><input type="button" onclick="getElements()" value="How many input elements?" /></body></html> Link to comment Share on other sites More sharing options...
Ingolme Posted July 3, 2009 Share Posted July 3, 2009 Hi,Why my alert does not work on Firefox but it works on IE?Thanks for your help<html><head><script type="text/javascript">function getElements(){var x=document.getElementsByTagName("input");alert(x(0).name);}</script></head><body><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><br /><input type="button" onclick="getElements()" value="How many input elements?" /></body></html> This line is wrong:alert(x(0).name); Use either: alert(x[0].name); or alert(x.item(0).name); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.