This is because you missed #in your selector.
Just try using the link thisinside this click event to achieve what you want,
$("#foldit").click(function () {
$(this).animate({"width": "165px"}, "fast");
});
According to your new requirement, you can try this,
$('#foldit').click( function() {
var toggleWidth = $(this).width() == 165 ? "100px" : "165px";
$(this).animate({ width: toggleWidth });
});
source
share