SolidJS - Button onClick not working | Community
Skip to main content
New Participant
November 17, 2023
Solved

SolidJS - Button onClick not working

  • November 17, 2023
  • 2 replies
  • 1632 views

Hello, 
can someone advice if I handle onClick with vanilla js is working but if I use the onclick with Solidjs is not working.
I do not get any errors:

 

 

import { JSX, createSignal } from 'solid-js';

import { render } from 'solid-js/web';




const App = (): JSX.Element => {

 

  document.addEventListener('DOMContentLoaded', function () {

    const button = document.getElementById('myButton') as HTMLButtonElement;

    button.addEventListener('click', function () {

      console.log('Experiment C - vanilla js');

    });

  });

  return (

    <>

      <button
        id="myButton"
        style={{ 'z-index': 3000, background: 'red' }}
      >

        click -JS
   
 
</button>
<button

        class="bttn-solid"

        style={{ 'z-index': 3000, background: 'red' }}

        onClick={() => console.log('Experiment C ')}

      >

        click me-Solid

      </button>


    </>

     

  );

};






 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sSimona

All good now

The issue was in the bundler

2 replies

New Participant
May 7, 2024

Hello,

 Hope this message finds you well

I just want to know how we connect AEM with soldJs.  

alexbishop
Employee
November 21, 2023

Where is it that you're trying to use that code?

sSimonaAuthorAccepted solution
New Participant
November 30, 2023

All good now

The issue was in the bundler