td值不在coolautosuggest jQuery函数中

td值不在coolautosuggest jQuery函数中,jquery,html,jquery-plugins,Jquery,Html,Jquery Plugins,我试图访问td函数中的coolautosuggest值,但它给出了未定义的值 HTML代码: <table class="table table-bordered cust_job_over"> <thead> <tr> <th>Skillset</th> <th>Assignee</th> </tr> </thead> <tb

我试图访问
td
函数中的
coolautosuggest
值,但它给出了
未定义的值

HTML代码:

<table class="table table-bordered cust_job_over">
  <thead>
    <tr>

      <th>Skillset</th>
      <th>Assignee</th>

    </tr>
  </thead>
  <tbody class="LabourTbody">
    <tr>

      <td width="45%">
        <input type="hidden" class="labourAssetID" value="31" name=""><span class="skill">0.35m Planer Operator</span></td>
      <td width="40%" style="position: relative;">
        <input type="hidden" class="" value="167,169,172,173" name="">
        <input type="text" class="form-control cool-auto-suggest" style="width: 90% !important;float:left;">
        <div class="assig_noti assign_complete cust_job_over_noti"></div>
      </td>

    </tr>
    <tr>

      <td width="45%">
        <input type="hidden" class="labourAssetID" value="33" name=""><span class="skill">Sweeper Driver (CE)</span></td>
      <td width="40%" style="position: relative;">
        <input type="hidden" class="" value="167,169,172,173" name="">
        <input type="text" class="form-control cool-auto-suggest" style="width: 90% !important;float:left;">
        <div class="assig_noti assign_complete cust_job_over_noti"></div>
      </td>

    </tr>


  </tbody>
</table>
这就是我得到未定义值的地方。
“/asset”:$(This.nextest('tr').find('td:eq(0.labourAssetID')

我正试图实现这一点

有谁能建议我如何在此函数中使用
类名
获取最接近的
td
输入值吗?

问题是
$(此)
引用文档对象,因为您位于
$(document).ready()事件的上下文中

如果您有多个
cool auto suggest
类,则需要迭代每个元素:

$(document).ready(function() {
  $(".cool-auto-suggest").each(function() {
    // Here I save reference to the current iterated object
    var $el = $(this);

    // Here I calling the plugin separately, for each '.cool-auto-suggest' 
    $el.coolautosuggest({
      url: window.location.origin + "/datalist/",
      showThumbnail: true,
      showDescription: true,
      additionalFields: {
        // Here I select the correct element using the reference ($el)
        "/asset": $el.closest('tr').find('td:eq(0) .labourAssetID') 
      },
      onSelected: function(result) {

      }
    });
  });
});
$(document).ready(function() {
  $(".cool-auto-suggest").each(function() {
    // Here I save reference to the current iterated object
    var $el = $(this);

    // Here I calling the plugin separately, for each '.cool-auto-suggest' 
    $el.coolautosuggest({
      url: window.location.origin + "/datalist/",
      showThumbnail: true,
      showDescription: true,
      additionalFields: {
        // Here I select the correct element using the reference ($el)
        "/asset": $el.closest('tr').find('td:eq(0) .labourAssetID') 
      },
      onSelected: function(result) {

      }
    });
  });
});