http://codepen.io/leongaban/pen/quzyx
Hi, basically the selector request
-row on specific td's which hit a click event in jQuery.
I'm able to get the number associated to the data-message-id
on the tr, however I'm having trouble finding the right way to target the name of the class which is on the image in the first td.
The HTML Markup:
<table>
<tr data-message-id="101010">
<td class="table-icon request-row">
<img class="accepted-icon" src="http://leongaban.com/_projects/whoat/_HTML/img/icon-orange-tick.png" alt="Accepted"/>
</td>
<td class="data-name request-row">
Name
</td>
<td class="data-career request-row">
Title
</td>
<td class="data-company request-row">
Company
</td>
<td>Some image goes here<!--Not clickable--></td>
</tr>
</table>
My jQuery
$(".request-row").unbind('click').bind('click', function () {
alert('clicked .request-row');
var $tr = $(this).closest("tr");
var id = $tr.data('message-id');
msg_id_incoming = id;
var userType = $tr.data('type');
// if accepted then change up the content displayed...
//var $status = $(this).parent.children('img').attr('class');
var $status = $(this).siblings('img').attr('class');
alert($status);
});
How would you re-write the code under the // if accepted then change up the content displayed...
comment, to get the class name that is on the image when a td with the class name request-row
is clicked?
My Codepen: http://codepen.io/leongaban/pen/quzyx