user2320325 user2320325 - 1 year ago 89
Javascript Question

How to concatenate variable in string in javascript

I am using this

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

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

But it not worked
It should be after concatenate like below

var atLeastOneIsChecked = jQuery('input[name="addon-base-bar2[]"]:checked').length;

Answer Source
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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download