user1652050
user1652050

Reputation: 153

removing a class from a jquerymobile page

I have a problem with jQuery Mobile. I have a hideOnInit class on a page. like this:

<div data-role='page' id='hi' class='hideOnInit'>

on a button click i want to remove the class='hideOnInit'.

I have tried

$('#idOfPage').removeClass('hideOnInit');

and without the . before hideOnInit, but it isn't working. could anyone help?

thanks in advance.

Upvotes: 0

Views: 86

Answers (2)

Adil
Adil

Reputation: 148178

You do not have to give . in removeClass with class name. Remove dot from class in parameter passed to removeClass.

You have div with id = hi but you are removing class from id = idOfPage

Live Demo

Change

$('#idOfPage').removeClass('.hideOnInit');

To

$('#idOfPage').removeClass('hideOnInit');

Change

<div data-role='page' id='hi' class='hideOnInit'>

To

<div data-role='page' id='idOfPage' class='hideOnInit'>

Upvotes: 2

Sridhar Narasimhan
Sridhar Narasimhan

Reputation: 2653

ClassName should be used inside the removeClass method i.e without . (.hideOnInit)

$('#idOfPage').removeClass('hideOnInit');

Thanks

Upvotes: 1

Related Questions