キャンセルボタンをクリックすると、最も近い「.myファイル」クラスを非表示にします。私は警告を取得し、キャンセルボタンが、隠れが動作していない上をクリックすると最も近いクラス/リンクタグを非表示
<div>
<label for="file">file</label>
<input type="file">
<a href="#" class="my-file">first file</a>
<button class="cancel-button" type="button">Cancel</button>
</div>
<div>
<label for="file">file</label>
<input type="file">
<a href="#" class="my-file">Second file</a>
<button class="cancel-button" type="button">Cancel</button>
</div>
$(function() {
$('.cancel-button').on('click', function() {
alert('works');
$(this).closest('.my-file').hide();
$(this).closest('a').hide();
})
})
:私はこれをしようとしています。私はここで何が欠けていますか?