これを試して:
$(this).parents('.container').css("width", width);
また、 .parents()
の代わりに .closest()
を使用してください。
.parents()
will go through the DOM all the way to the root element, HTML, and THEN filter the result based on your selector. .closest()
, on the other hand, will stop as soon as a match is found.
すべてのコードをひとつの行にまとめることができます:
$(this).closest('.container').css("width", (width < 200 ? 200 : width ) );
これが助けて欲しい!