CRM 2011 JS: Get and Set attribute value in CRM 2011

This is how to Get and Set attribute value using javascript in CRM 2011

Get Attribute Value
var name = Xrm.Page.getAttribute("attributename").getValue();

Set Attribute Value
Xrm.Page.getAttribute("attributename").setValue('Navish');