I've done this code but the element inspector tells me that boton
is set, the exact error is this:
Uncaught typeerror: Can not read property onclick of undefined.
The point is that when I paste the code in the element inspector it works but when I save it in the html it is not as if the variable boton
loses its value, in fact I check it in the element inspector and when I loading the web gives me error, but if I do it step by step it works. Does anyone know why?
Thanks in advance, then I leave the code:
var boton = document.getElementsByClassName('ShowMore')[0];
console.log(boton);
if (boton!=false){
console.log("existe el boton");
boton.onclick("jq('#jqSectionText').toggle();jq(this).toggleClass('ShowLess'); jq(this).toggleClass('ShowMore');jq(this).find('.fa-chevron').toggleClass('fa-chevron-up fa-chevron-down');");