I want to open a chat (already scripted in my header) when I click on a button using jquery.
I have the code working using HTML but I'm willing to translate it into jquery. But I'm not familiar with it, nor to write it.
<div class="XXX" id"YYY" onclick="customPlugin.command('WebChat.open');">Start Tchat</a></div>
Here is what i came from but it's not working :
jQuery(function ($) {
$( document ).ready(function() {
$("XXX").on("click", function customPlugin.command('WebChat.open'){
});
});
});
I don't know where to insert my function, nor how... Anyhelp would be very much appreciated! Thanks
CodePudding user response:
First of all to select elements by class you should use the point before the class name in JQuery
Then you need to call your function from inner anonymous function in click method, something like this:
$(document).ready(function() {
$(".XXX").on("click", function() { customPlugin.command('WebChat.open') });
});
CodePudding user response:
in line 3 of your jquery file you should write $(".XXX")