views:

25

answers:

2

Hey all, I am not quite getting why this doesn't seem to be working. The alert pops out the correct id, but the removeClass does not seem to be firing. What am I doing wrong?

function testClassSwitch(t_id) {
    alert("Do things to a button with this ID: " + t_id);
    $(t_id).removeClass("add-button");
}

Thanks!

+5  A: 

Does your t_id have the # id selector on it?

rosscj2533
Oh, son of a! *facepalm* Thanks so much, something so simple. ;-/
TwstdElf
No worries TwstdElf. This one is easy to miss :P.
Stefan Kendall
@TwstdElf - agreed, easy mistake to make :)
rosscj2533
+3  A: 

add # before the id like this

function testClassSwitch(t_id) {
    alert("Do things to a button with this ID: " + t_id);
    $('#' + t_id).removeClass("add-button");
}
Teja Kantamneni
Works for me: http://jsfiddle.net/sBJwJ/
Squeegy