0

I was trying to make style for checkbox,radio button and select box.
I got a plugin from ryanfait [ http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ ] and works well if we code HTML as he mentioned.

Now, my issue is something different. The HTML code will look like this.

<label class="checkBox">
    <input type="checkbox" id="rememberMember" class="styled"/>
    Remember me
</label>

OR

<input type="checkbox" id="rememberMember" class="styled"/>
<label class="checkBox" for="rememberMember">Remember me</label>

On clicking on the checkbox - it is not showing the tick mark.
On clicking on the 'Remember me' text - It is showing the tick mark.

I think the issue is with label.

Is there any possible way (editing the JS file) ? JS file : http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/custom-form-elements.js

I put in JSfiddle but it is not loading the image !!
http://jsfiddle.net/smilyface/pXETM/1/

1
  • edited for closing input tags. Commented Feb 24, 2014 at 9:10

4 Answers 4

1

Download js and css from Styled checkbox and radios

Working Demo

Full Code

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <link rel="stylesheet" href="http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/form.css" />
  <script src="http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/custom-form-elements.js"></script>
</head>
<body>
  <input type="checkbox" id="rememberMember" class="vAlignMiddle styled" name="remember_member_id" />
<span class="checkBoxLabel">Remember me</span>
  <br/>
  <label>
    <input type="radio" class="styled" name="radio"/> Yes
</label>
<br/>
<label for="radio_no"> 
<input type="radio" class="styled" name="radio" id="radio_no">
No</label>
</body>
</html>

Demo

Sign up to request clarification or add additional context in comments.

Comments

0

It may be conflict in js file, You can find the jquery error in console of the web browser. To solve this error you need to identify the solution of that console error.

2 Comments

No. I couldnt see any error in console. I am using firebug.
I suggest you to use google chrome rather than firebug, Google chrome is more helpful to find issues regarding js conflict.
0

A potential solution would be to assign your input field an identifier and apply

$( "#myObj" ).click(function() {
    // This is what gets executed onClick
    $( "#myCheckbox" ).prop("checked", true);
});

2 Comments

Where I need to add this in the custom-form-elements.js ?
Inside of some event. Tailor the selector to your implementation.
0

try this code. this will check your checkbox in onclick of label with class 'checkbox'

<script>
    $('.checkBox').click(function() {
      $("#rememberMember").prop("checked", true);
    });
</script>

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.