javascript - Can not check if input has value or not -
i want loop through array of ids , check if value exists or not , stuff code below:
function checkbillingfields() { var inputids = [ "#billing_first_name", "#billing_last_name", "#billing_company", "#billing_phone", "#billing_address_1", "#billing_address_2", "#billing_city", "#billing_city"]; var arraylength = inputids.length; (var = 0; < arraylength; i++) { console.log(inputids[i]); if ($("inputids[i]").val().length == 0){ $('.woocommerce-billing-fields__field-wrapper').appendto('.billing-fields'); $(".billing-heading").css({'margin-top': '100px'}); }else{ $(".expand-billing").css({'display': 'none'}); } } } checkbillingfields(); i error cannot read property 'length' of undefined. use local storage store inputs , works fine tested.
any ideas helpful been researching , trying fix nothing worked.
just console.log() use same in if statement
console.log(inputids[i]); if ($(inputids[i]).val().length == 0){ inputids[i] // returns #billing_first_name if = 0
"inputids[i]" return "inputids[i]"
Comments
Post a Comment