-1
I’m doing a web development for a joomla site.
When I do:
jQuery('.encomendas tbody').on('click', 'td.details-control', function () {
$(this).toggleClass('diminuir');
if ($(this).hasClass('diminuir'))
$(this).innerHTML = '-';
else
$(this).innerHTML = '+';
// ...
});
This works, i.e., I select an element in jQuery and change the value of the property innerHTML
javascript.
Before I was using the method .text()
$(this).toggleClass('diminuir');
if ($(this).hasClass('diminuir'))
$(this).text('-');
else
$(this).text('+');
Always got the bug,
uncaught typeerror $(...). text is not a Function
I spent hours trying to understand this behavior, without result. Until I tried to stupidly use the innerHTML
and it worked.
What is wrong?
There is something wrong with your question. The
.innerHTML
does not work with jQuery objects, and the.text()
should work, since it is a method since the first version of jQuery.– Sam
AP, note that I edited your publication and improved the formatting of it. When posting a new question/answer watch out for the formatting of it, it helps who is reading. In [meta] there are very interesting formatting guides, I recommend reading.
– Jéf Bueno