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,

asked Sep 3, 2013 at 13:00
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/

answered Sep 3, 2013 at 13:02
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(); 
 }
});
answered Sep 3, 2013 at 13:16

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.