Use javascript object in attr function