javascript - IE won't toggle element -


I have javascript on this page to toggle between a java and switch between two images

  & lt; Script type = "text / javascript" & gt; Function ToggleArchive () {document.getElementById ('Cat'). Toggle (); Var image = document.getElementById ('arrows'); If (image.src == 'bullet_arrow_down.png') {image.src = 'bullet_arrow_up.png'; } Other {image.src = 'bullet_arrow_down.png'; }} & Lt; / Script & gt;  

Works fine on modern browsers, but IE says there is an error in that line

  document.getElementById ('cat'). Toggle ();  

So it does not toggle the div nor switches the image. What is the plan?

It seems that as you are using prototype JS library, the library will add methods of DOM elements In this particular case, it is adding HTMLElement.prototype.toggle . The DOM prototype is supported only in IE8 and later and should be rendering in standard mode. To make it work in all browsers, use getElementById () :

  $ ('cat') instead of  $ ()  method Please. ') .toggle ();  


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -