Queryselector Set Text Value
I have this loop which should set the value to none and update the placeholder. When I log the node it works fine but the value and placeholder are not u
Solution 1:
You shouldn't parse an object just use it :
var data= {"password":"password","username":"xhinii"};
for(var prop in data) {
document.querySelector('input[name = "' + prop + '"]').value = prop;
document.querySelector('input[name = "' + prop + '"]').setAttribute('placeholder', data[prop])
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputname='password' /><inputname='username' />
Post a Comment for "Queryselector Set Text Value"