I have no idea why this doesn't work.
JQuery:
$("#foldit").click(function () {
$("foldit").animate({"width": "165px"}, "fast");
});
Its because you have missed #
in your selector.
Just try to use the this
reference inside that click event to achieve what you want,
$("#foldit").click(function () {
$(this).animate({"width": "165px"}, "fast");
});
As per your new requirement you can try like this,
$('#foldit').click( function() {
var toggleWidth = $(this).width() == 165 ? "100px" : "165px";
$(this).animate({ width: toggleWidth });
});
You missed '#'
in the selector and alternatively you can use it like this as well
$("#foldit").click(function () {
$(this).animate({"width": "165px"}, "fast");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With