1

i have a checkbox array name "skills[]" and i want add a text to side of clicked(checked) checkbox(whithout Submit) my code like this:

<li><input name="skills[]" class="skills" value="1" type="checkbox" /></li>
<li><input name="skills[]" class="skills" value="2" type="checkbox" /></li>

wutdo? Thanks,

0

2 Answers 2

1
$('input.skills').on('change', function() {
    if($(this).is(':checked'))
    {
        $(this).parents('li').append('<span class="text">your text</span>');
    } else {
        $(this).parents('li').find('.text').remove();   
    }
});

Working jsfiddle: http://jsfiddle.net/V3TZn/4/

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

Comments

0

Try this: DEMO

 $("input[name='skills[]']").change(function(){
    if($(this).is(':checked')){
       $(this).parents('li').append('<span class="text">your text</span>');
    } 
    else {
    $(this).parents('li').find('.text').remove();   
    }
});

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.