1

I'm trying to use jQuery .button() on a checkbox, but i can't understand why this is'not working.

this is the javascript code:

$('#login_checkbox').button();

and this is the html code:

<input id="login_checkbox" type="checkbox" value="login_remember"/><label>Remember me</label>

I'm doing everything exacly as shown here: http://jqueryui.com/demos/button/#checkbox

1
  • Your code looks fine, did you install jQuery UI along with jQuery? Commented Oct 17, 2010 at 19:23

2 Answers 2

2

Add in the for attribute or it won't know which label to use:

<label for="login_checkbox">Remember me</label>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Hogan! You save me an headache! I hate those kinds of mistakes!
@Silvio accept his answer to make me feel a little less cheap for guessing at something that wasn't your actual problem :-)
1

Is that code running in a "ready" handler, or just naked in a <script> block in the head of your page?

In other words, are you sure that the element exists at the time the Javascript code runs? That's a really easy mistake to make, especially when throwing together little proofs-of-concept.

1 Comment

The JS code is inserted along with other working lines: $(function() { $('#tac').hide(); $('#username_error').hide(); $('#password_error').hide(); $('#email_error').hide(); $('#login_checkbox').button(); $('#login_choice_container').buttonset(); }); .The only thing not working is $('#login_checkbox').button(); :S

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.