Reputation: 8463
My Code..
if($("#edButtonHTML").is(".active")) { $("#edButtonHTML").removeClass("active"); $("#edButtonPreview").addClass("active"); }
I need to remove active class from element #edButtonHTML and add to #edButtonPreview Unfortunately not functionating...Help me
Upvotes: 1
Views: 252
Reputation: 41
Since you didn't post your HTML, we can't offer a definitive answer. But a couple of suggestions:
Use a JavaScript debugger (I like Firebug) to put a break point inside your "if" condition, to see if code execution ever gets there.
If you're convinced the remove function isn't working, post a question in a JQuery forum, or submit a bug report on the JQuery site.
Upvotes: 0
Reputation: 3078
My suggestion is do some old school approach. Put an alert statement inside the if statement to see if it was really raised.
alert("Before if condition.");
if($("#edButtonHTML").is(".active"))
{
alert("Condition was satisfied");
$("#edButtonHTML").removeClass("active");
$("#edButtonPreview").addClass("active");
}
Old school but it works for debugging. But you can use firebug, IEDebugbar or any other browser debugging tool to check if your javascript worked fine.
Upvotes: 0
Reputation: 3183
Don't think the if-statement will resolve. You can always add an alert statement inside the if to check. Another option to use is hasClass("active"), so
if ($("#edButtonHTML").hasClass("active") {
//go on
Upvotes: 0
Reputation: 8117
Change your if condition to [assuming active is your class name
if($("#edButtonHTML").hasClass("active"))
{
$("#edButtonHTML").removeClass("active");
$("#edButtonPreview").addClass("active");
}
Upvotes: 3