DDan DDan - 1 year ago 70
Javascript Question

HTML class not removed

See my example here: https://jsfiddle.net/ddan/xvq6ofhh/


$(function() {
var listEditPane = $('#editpane');

console.log($(listEditPane).find('.input-highlight').length); // 2
console.log($(listEditPane).find('.input-highlight').length); // still 2 ???

The class is not removed, the length is still staying the same. What am I missing?


Answer Source

The .removeClass() method expects the name(s) of the class(es) to remove, but you are passing a selector '.input-highlight'. Remove the . from the beginning:


Demo: https://jsfiddle.net/xvq6ofhh/1/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download