How do I add code for a button in java script editor? | XM Community
Skip to main content
I created a button in the html editor and a function that is executed when it is pressed. This works, however, I would like to write the function in the java script editor, but when I write it there, it is ignored. Can anyone tell me what I am doing wrong? I don't know how the two texts (html and java script) are combined

Thank you!
Hello @Mauricio ,



Assign an unique id attribute to your created button. In javascript under the js(onReady) function write the function using the `on('click')` event of the button as:



jQuery("#BUTTON_ID").on('click',function(){

//function goes here

});
Thank you, Shashi! I am so ignorant that I had to find out what jQuery means 😕

First, I wrote literally jQuery, but it didn't work, so I searched a bit more and replaced it with $ and it works 🙂 Thanks
> @Mauricio said:

> Thank you, Shashi! I am so ignorant that I had to find out what jQuery means 😕

> First, I wrote literally jQuery, but it didn't work, so I searched a bit more and replaced it with $ and it works 🙂 Thanks



Your search appreciated, however `jQuery `should have also worked

Leave a Reply