This seems like overkill and I would like to refactor this...any suggestions
if($(this).text() == \"Grocery\"){ $(\".type_changer\").attr(\"id\",
var textToVal = { "Grocery" : "gro", "Restaurant" : "res" // and so on ... }; for (var text in textToVal) { if ($(this).text() == text) $(".type_changer").attr("id", textToVal[text]); }