Sajid Anwar Sajid Anwar - 2 months ago 4x
Javascript Question

How to insert two value in one time to array using JavaScript

I want to insert two values in one array in each loop. I have tried

feature_arr = [];
$form.find( '.variations .value' ).each( function() {
var $radios = $( this ).find( 'input[type=radio]' );
var $checked_radio = $radios.filter(':checked');
var attribute_name = $radios.attr( 'name' );
feature_arr[] = attribute_name1;
feature_arr[] = $checked_radio.val();

I want array this form
["1", "Brighton_Black", "2", "Frame_Base", "3", "Matching_upholstery", "6", "Headrest", "7", "Covered"]

But give me error this code


try this

var feature_arr = new Array(); // define the array or you can use feature_arr = []

and inside your condition