这是我的 HTML 片段。我正在订阅锚点“查询”的“点击”事件。我如何遍历以获得data-driverid
价值?
<div class="DriverWrapper" data-driverid="108WW" style="background-color: Silver; padding: 4px 4px 4px 4px; page-break-before: always;">
<strong>Driver ID:</strong> 108WW
</div>
<table style="width: 100%;">
<tr>
<td style="vertical-align: top; width: 20%">
<strong>174794</strong>
<a href="#" class="inquireTripLink">inquire</a>
编辑:
我试过这个,它显示警报null
$(".inquireTripLink").on("click", function (event)
{
event.preventDefault();
var driverId = $(this).closest('.DriverWrapper').data('driverid');
alert(driverId);