user1785870
user1785870

Reputation: 477

jQuery removeclass doesn't work

$('.shortcode').removeClass('.shortcode');
$('.shortcode').hide();

Why .shortcode items gets hidden anyway? In source code they still have shortcode class.

Upvotes: 0

Views: 1418

Answers (2)

raina77ow
raina77ow

Reputation: 106375

You shouldn't use . in the string passed to removeClass: this...

$('.shortcode').removeClass('shortCode');

... is sufficient. Think of it: if method is intended to remove a class anyway, why should you mark its argument with the class sigil (.)? :)

With dot in front of the real className, jQuery tries to remove '.shortCode' class - obviously, it's a no-op here.

Upvotes: 5

toxicate20
toxicate20

Reputation: 5410

Remove the dot '.'. This will work

$('.shortcode').removeClass('shortCode');

Upvotes: 11

Related Questions