Data-target doesnt work at all


Hey guys,

When i try to use target, i get this error:

TypeError: undefined is not an object (evaluating 'this.homeTarget.innerHTML'

this.homeTarget is undefined


<div class="home" id="home" data-controller="main" data-action="click->main#start_quiz" data-target="main.home">
	<div class="home__wrapper">
		<div class="home__heading">BEM VINDO AO QUIZ</div>
		<div class="home__subheading">TOQUE NA TELA PARA INICIAR</div>


import { Controller } from "stimulus"
export default class extends Controller {
	static targets = [ "home" ]
        start_quiz() {
		console.log("home:", this.homeTarget.innerHTML)

What’s wrong here?


Have you tried not chaining it?

const home = this.homeTarget;
let homeHTML = home.innerHTML;


This was resolved in