Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using this

var abc = jQuery('#pl_hid_addon_name').val(); 
alert(abc);

var atLeastOneIsChecked = jQuery('input[name="addon-"'+abc+']:checked').length ;
alert(atLeastOneIsChecked);

But it not worked It should be after concatenate like below

var atLeastOneIsChecked = jQuery('input[name="addon-base-bar2[]"]:checked').length;
share|improve this question
up vote 2 down vote accepted
var atLeastOneIsChecked = jQuery('input[name="addon-"'+abc+']:checked').length;
                                                    ^
                                                    |

You used the closing " at the wrong place

var atLeastOneIsChecked = jQuery('input[name="addon-'+abc+'"]:checked').length;
                                                           ^
                                                           |
share|improve this answer
thanks for reply it's work – user2320325 May 1 at 6:18

Try this -

var atLeastOneIsChecked = jQuery("input[name='addon-"+abc+"']:checked").length ;
share|improve this answer
thanks for reply it's work – user2320325 May 1 at 6:18

Concatenate like this:

var atLeastOneIsChecked = jQuery('input[name="addon-'+abc+'"]:checked').length ;
share|improve this answer
1  
The name's value will break the selector if there's any special characters like [, because you've removed quoting. – Ian Apr 30 at 15:02
1  
@Ian ya correct, didn't saw it – A. Wolff Apr 30 at 15:03
thanks for reply it's work – user2320325 May 1 at 6:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.