テーブルのセルに内容を表示する必要があります。jqueryを使って別のtdをクリックすることで、特定のクラス名を持つtdの値を表示する方法は?
表は以下の通りです:
<table id="innertable">
<thead>
<tr class="tablewrapperheader">
<th>Status</th>
<th>Date Requested</th>
<th>Date Time Range</th>
<th>Reason</th>
<th>Date Approved/Denied</th>
<th>Reason Denied</th>
<th>Approve/Deny</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td id="check" class="pending"><img src="../images/icons/36x36/exclamation.gif" alt="exclamation"/>
<span id="checkMsg">Pending</span></td>
<td>06/15/2012</td>
<td>06/21/2012</td>
<td>Medical Checkups</td>
<td class="dateApproveDenied"></td>
<td class="reasonDenied"></td>
<td><img src="../images/icons/128x128/approve.png" class="actionApprove" alt="exclamation" height="16" width="16"/> <img src="../images/icons/128x128/deny.png" class="actionDeny" alt="" height="16" width="16"/></td>
</tr>
ユーザーがアクティブにクリックするか、拒否し、拒否した場合、彼らは拒否の理由を与える必要があります。私は、拒否の日付と理由を、私がクラス名 "dateApproveDenied"と "reasonDenied"を使用している、尊重されたtdに表示しなければなりません。私はこの影響を達成するためにJqueryを使用していますが、無駄です。
は、ここで私はその理由が、その理由を書いて、日付がTDに表示されないために、プロンプトを取得し、私のjqueryの
$(".actionDeny").click(function(){
var reason = prompt("Write reason for denial.",'');
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //js months 0-11
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = mm+'/'+dd+'/'+yyyy;
$(this).closest('td .dateApproveDenied').text(today);
$(this).closest('td .reasonDenied').text(reason);
});
です。誰かが私にそれを正しく設定するのを助けてください。ありがとう
を、 'reasonDenied'は' id'ですが、あなたのjQueryのセレクタは 'としてそれを見つけようとしていますクラス '。 – David
ご協力いただきありがとうございます。私は自分のコードでそれを修正し、同様に....しかし、私はまだtdの値を取得していません。 – Parth