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
JavaScriptjQuery

Avatar of undefined
Last Comment
SAbboushi
SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of SAbboushi
SAbboushi
Flag of United States of America image

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
Avatar of SAbboushi
SAbboushi
Flag of United States of America image

ASKER

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..
Avatar of SAbboushi
SAbboushi
Flag of United States of America image

ASKER

I tried
JQuery( "input[name^='ff_nm_next']" ).addClass("bfNextButton");

Open in new window

but that didn't seem to work...
Avatar of SAbboushi
SAbboushi
Flag of United States of America image

ASKER

Got it:
JQuery( "button[name^='ff_nm_next']" ).addClass("bfNextButton");

Open in new window

JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo