getElementbyID from controller, help

Hi all!

maybe someone can help me…
I have different div each one with a different id.
I want to do this in my stimulus_controller

connect(){
this.elementTarget.innerHTML = document.getElementbyID(“xx”)
}
but is not taking the document.getElementbyID… what can I do in order to get the div id= “xx”???

Question n2, how do I get a target with his Id or his value?

thanks!

Have you tried adding .innerHTML after your getElementById? Also, you’ll have to rewrite to use getElementById and not getElementByID (lowercase d instead of uppercase D).

connect(){
  this.elementTarget.innerHTML = document.getElementbyId(“xx”).innerHTML
}