How to add a class to the textarea’s parent div when clicked or focused?
$(document).ready(function () {
$('textarea').toggleClass(function() {
if ($(this).parent().is('.expandingArea')) {
return $(this).parent().addClass('open');
} else {
return $(this).parent().removeClass('open');
}
});
});
You can just use focus and blur to get this functionality.
DEMO
Another One