javascript - add attribute to input from array; however, using value pair from jsaon -
i'm getting error: setattribute' on 'element': 2 arguments required, 1 present.
i want add attributes input i'm avoiding repeats:
//putholder.setattribute("placeholder", "product name (required)"); //putholder.setattribute("ng-model", "vm.product.productname"); //putholder.setattribute("ng-minlength", "4"); //putholder.setattribute("ng-maxlength", "12"); //putholder.removeattribute("size");
i have used following code can't right:
var putholder = document.getelementbyid('customerid'); //var result = '{"placeholder":"product name (required)","ng-model":"vm.product.productname","ng-minlength":"4", "ng-maxlength":"12"}'; //$.each($.parsejson(result), function (k, v) { // putholder.setattribute(k + ' = ' + v); // }); //or js please prefer javascript json.parse('{"placeholder":"product name (required)","ng-model":"vm.product.productname","ng-minlength":"4", "ng-maxlength":"12"}', function(k, v) { putholder.setattribute(k + ' = ' + v); });
i've tried loop 1 elem so:
var names = ["size", "value"]; (var = 0; < names.length; = ++i) { var cadauno = names[i]; putholder.removeattribute(cadauno); }
i hope can thanks.
Comments
Post a Comment