<script> var countChild = document.getElementById('get-price'); alert('WORK') //работает </script> 

what if

 <script> var countChild = document.getElementById('get-price').children[1]; alert('WORK') //а тут уже не работает </script> 

Moreover, .innerHTML also leads to inoperability. Everything works on a locally saved page, but not on the server. This code is inserted into the VamShop page. Can someone tell me what could be the catch?

  • and the element with the get-price id is exactly present in the document at the moment the script is triggered? just if the script is located before the body, then document.getElementById('get-price') returns null, and trying to call properties and methods will result in an error - Specter
  • and you can link to the option on the server? - Gena Tsarinny
  • Indeed, getElementById returns null. But how? A div with this id goes just below the <script> </ script> insert (by the way, it can be used to find this piece of code, it's there alone) zverushka.org.ua/final/… - Andrey Stifurak
  • > But how? div with this id goes just below the insert <script> </ script> smiled - Specter
  • but what is the problem?) - Andrey Stifurak

1 answer 1

What in the console error pops up? The easiest catch can be that there is no element on this page with id = 'get-price'.

  • Above gave a link - Andrey Stifurak