I’m using jQuery for a dynamic content behavior on a website. I’ve got an error:
TypeError: $(“#id”).attr(“src”,
thisContent.attr(“data-attr”)).show is not a function
Firstly I thought that it was browser related, but it turns out that it isn’t. The error is on this line:
$('#id').attr('src', thisContent.attr('data-attr')).show();
If the second argument of
.attr()isundefinedthe getter will be invoked.Seems like the getter is invoked instead of the setter.
Getter:
Setter:
thisContent.attr('data-attr')might returnundefinedin some cases, and therefor the getter gets invoked instead of the desired setter method.