addAttr not working in jquery? addAttr not working in jquery? jquery jquery

addAttr not working in jquery?


It's called .attr(), not .addAttr().

You should also replace your inner $('#color') with $(this) to indicate that you're manipulating the same input that's being changed:

$('#color').change(function(){    $(this).attr('value', 'test');});


You are confused about removeAttr() and you think that addAttr() exists, that's wrong.

The function you want is .attr() - nowadays .prop(), I believe.


You could also do:

$('#color').change(function(){    $(this).val('test');});