Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

SolidJS - Button onClick not working

Avatar

Level 1

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>


    </>

     

  );

};






 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 1

All good now

The issue was in the bundler

View solution in original post

2 Replies

Avatar

Employee Advisor

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

Avatar

Correct answer by
Level 1

All good now

The issue was in the bundler