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
SAbboushiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
$(document).ready(function() {
  $('button.ff_elem').addClass('bfNextButton');
});

Open in new window

0
leakim971PluritechnicianCommented:
$(document).ready(function() {
    
    // YOUR CURRENT CLICK
    $("#ff_elem961").click(function(evt) { // WE use the ID no the CLASS
        evt.preventDefault();
        if(typeof bf_htmltextareainit != 'undefined'){
            bf_htmltextareainit()
        }
        populateSummarizers();
        if(document.getElementById('bfPaymentMethod')){
            document.getElementById('bfPaymentMethod').value='';
        };
        ff_validate_nextpage(this,'click');
    });
    
    // jquery to change class of element
    $("#ff_elem961").removeClass("ff_elem").addClass("bfNextButton");

    // add bfNextButton class, will not remove ff_elem
    $("#ff_elem961").addClass("bfNextButton");

    // overwrite all class and set only bfNextButton class, will remove ff_elem and any other
    $("#ff_elem961").attr("class", "bfNextButton");
    
})

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SAbboushiAuthor Commented:
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
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

SAbboushiAuthor Commented:
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..
0
SAbboushiAuthor Commented:
I tried
JQuery( "input[name^='ff_nm_next']" ).addClass("bfNextButton");

Open in new window

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

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.