addAttr not working in jquery?

jquery

Solution

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');
});

Problem

I have a sample code : ``` <input type="text" name="color" id="color" value="" /> ``` And jquery ``` $('#color').change(function(){ $('#color').addAttr('value', 'test'); }); ``` When I change value in textbox is result `value=""` and error in firebug `$("#color").addAttr is not a function` How to fix it ?

Original source