In general, the problem is such that I have many class elements and for each function is called passing the object id to js and already there is some magic that at the end changes the value via inner.html:

(js file is up and running).

<body> <div class = "example"> <SCRYPT> testing(id); </SCRYPT> </div> </body> 

In a function in which I, for example, want to change the value of only the first element, I write the following:

 function testing(id){ document.get.ElementsByClassName("example")[0].innerHTML = "zB"; } 

The funny thing is that in Chrome, FireFox this option works, but in Opera and IE nothing happens.

And I also tried to call this function directly from html, everything works well in all browsers.

How to solve: 3

1 answer 1

getElementsByClassName is supported in IE only starting from version 9. In older versions, you need to saw solutions-polyfill, as per the link in the comment to the question or just use jQuery: $(".example").first().html(...)

Second, you have an unusual example - <script> nested inside the element that you are going to edit. This is a good way to run into differences in parsers, since the code in <script> runs synchronously with the parsing. The best thing is not to do this, but if you want to pamper yourself, then at least give a complete example in which the problem is reproduced.