jqueryでthis
オブジェクトを使用して親要素を実現するにはどうすればよいですか。$.post
私が見たものは、それをログに記録すると、リクエストの詳細$(this)
に関する情報が得られます。またはオブジェクトPOST
を使用して、最も近い要素または親要素をどのように達成できますか。this
any element
this
がリクエストのオブジェクトであることを知ったPOST
ので、リクエストの詳細を取得します。
HTML
<table>
<tr>
<td><span class="remove-file-confirm" id="aa" file-name="whatsup"></span></td>
</tr>
<tr>
<td><span class="remove-file-confirm" id="bb" file-name="gotstuck"></span></td>
</tr>
</table>
脚本
$(".remove-file-confirm").click(function(){
var rconfirm = confirm("Are you sure, want to delete this file");
if (rconfirm) {
var rfileid = $(this).attr("id");
var rfilecode = $(this).attr("file-name");
$.post("ajx_delete_file.php", {fid:rfileid, fcd:rfilecode}, function(return_datad){
if (return_datad == "good") {
var k = $(this);
//$(this).closest("<tr>").hide();
console.log(k); // show information on post request
// how can i achieve .remove-file-confirm nearest tr element
} else {
alert("Cannot delete this file");
console.log(return_datad);
}
});
}
});