Link to home
Create AccountLog in
Avatar of SAbboushi
SAbboushiFlag for United States of America

asked on

jquery to change class of element

Hi-

Can someone help me: I need the jquery statement to change the class of the button below from ff_elem to bfNextButton and the jquery code to instead add bfNextButton to the class (instead of replace the class value)

<button class="ff_elem" value="Next PAGE" onclick="if(typeof bf_htmltextareainit != 'undefined'){ bf_htmltextareainit() }populateSummarizers();if(document.getElementById('bfPaymentMethod')){document.getElementById('bfPaymentMethod').value='';};ff_validate_nextpage(this,'click');return false;" type="submit" name="ff_nm_nextpage1[]" id="ff_elem961"><span>Next PAGE</span></button>

Open in new window


Thanks-
Sam
SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of SAbboushi

ASKER

thanks Padas--

I think that will add the class to all ff_elem buttons; can you please modify that to be specific to the button with class ff_elem and has a name that begins with "ff_nm_next" so this will work for name="ff_nm_nextpage1" and name="ff_nm_nextpage2 etc..

Also, how would I replace the class instead of adding it? (i.e 2 different scenarios)

Thanks again
leakim971 - thanks!  great documentation too.

Unfortunately I can't use ID this time... can you please modify that to be specific to the button with class ff_elem and has a name that begins with "ff_nm_next" so this will work for name="ff_nm_nextpage1" and name="ff_nm_nextpage2 etc..
I tried
JQuery( "input[name^='ff_nm_next']" ).addClass("bfNextButton");

Open in new window

but that didn't seem to work...
Got it:
JQuery( "button[name^='ff_nm_next']" ).addClass("bfNextButton");

Open in new window