0

I have inputs working for a color selector but I'm missing something when it comes to radio inputs.
I'd appreciate any help
This is the fiddle http://jsfiddle.net/mpxgC/1/

-------HTML---------

<div>
<label>
    <input class=width name=group1 value=1px type=radio />1px
</label>
<label>
    <input class=width name=group1 value=2px type=radio />2px
</label>
</div>
<div class=number2></div>

-------CSS---------

.number2 {
    width:100px;
    height:100px;
    border:2px solid #000000;
    border-width:3px;
}

-------jQuery---------

$("input[name='group1']:radio").change(function (){
if(this.checked) {$("div.number2").css('border-width',$('.width').val());}
});

3 Answers 3

3

Change your jQuery to just:

$("input[name='group1']").change(function () {
        $("div.number2").css('border-width', $(this).val());
});

jsFiddle example

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

Comments

0

Should be $('.width').text().trim() instead of $('.width').val()

Comments

0

try this

<div>
<label>
    <input class=width name=group1 value=1px type=radio id="radio1" />1px
</label>
<label>
    <input class=width name=group1 value=2px type=radio id="radio2" />2px
</label>
</div>

$("#radio1,#radio2").change(function (){
if(this.checked)
{$(".number2").css('border-width',$(this).val());}
});

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.