TypeError HTMLSpanElement does not have a 'html' method

I get an error

Uncaught TypeError: Object #<HTMLSpanElement> has no method 'html'

When I run this method

$("input[name=advancedSettings]").change(function() {
  $('span[id^="sFile"]').each(function() {
    this.html('Hey');
  });
});

And span should, of course, have a method called text and html, and I tested with

+5
source share
1 answer

You should run .html()in the jquery object:

$(this).html('Hey');
+18
source

All Articles