0

I have some CCS defined as following:

.FW_Buttons {
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px; 
    background-color: #123456;
}

and I want to add it to a button defined like this:

<div id="but_begin"><button type="button" id="but2_begin">Go</button></div>

using JQuery (in document-ready):

$("#but2_begin").css("FW_Buttons");

but the css is not applied on the button. I have checked with FireBug: it is not there. No error is triggered when using a breakpoint.

What am I doing wrong? Thanks.

3 Answers 3

6
$("#but2_begin").addClass("FW_Buttons");
Sign up to request clarification or add additional context in comments.

Comments

5

$("#but2_begin").addClass("FW_Buttons");

You want to use addClass() not css().

Demo

Comments

4

.css is used to set/get css elements, in order to set a class you can use .addClass()

$("#but2_begin").addClass("FW_Buttons");

Make sure to take a look at other methods to deal with css classes, they may be usefull for you in the future:

.removeClass()
.toggleClass()
.addClass()
.hasClass()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.