0

我有一个由以下行组成的表:

<tr>
  <td>
    <a href="http://www.google.com/">Link</a>
  </td>
  <td>It takes about 3 seconds for a search instead of the normal .3 seconds.
  </td>
  <td>
    <input type="text" class="priority" size="3" value="-5"/>
  </td>
  <td>
    Functionality
  </td>
  <td>
    8/1/2012 6:57:03 AM</td><td>FarQuad
  </td>
  <td>
    <select class="assign">
      <option value="No One" selected="selected">No One</option>
      <option value="Landon" >Landon</option>
      <option value="Steve" >Steve</option>
      <option value="Brandon" >Brandon</option>
    </select>
  </td>
  <td>
    <select class="status">
      <option value="Unassigned" selected="selected">Unassigned</option>
      <option value="Assigned" >Assigned</option>
      <option value="In Progress" >In Progress</option>
      <option value="Completed" >Completed</option>
    </select>
  </td>
  <td>
    <input type="text" class="notes" value="Super notes"/>
  </td>
  <td> 
    <input type="button" id="16" Value="Save" onclick="updateThisIssueRow(this)" />
  </td>
</tr>

请注意,最后一个单元格包含一个按钮,该按钮将通过 ajax 对数据库执行更新。

这是该方法的开始:

        function updateThisIssueRow(thisRowsButton) {

            var issueIDInput, newPriorityInput, newAssignPersonInput, newIssueStatusInput, newIssueNotesInput;

            var $currentRow = $(thisRowsButton).parent().parent();

            issueIDInput = thisRowsButton.id;
            newPriorityInput = $currentRow.children().eq(2).children().first().val();

            alert("Value of newPriorityInput is: " + newPriorityInput);
.
.
.

现在,我基本上需要使用 jQuery 获取 issueIDInput、newPriorityInput 等的值,然后将它们提供给 ajax 函数的其余部分,该函数有效。我正在为这些值寻找对读者更友好的 jQuery 选择器。我知道我可以像为 newPriorityInput 所做的那样获取所有内容(这很有效),但我的老板对 jQuery 了解不多(因此不喜欢/不信任它)。这些是否有更直观的选择器?

任何帮助是极大的赞赏

4

1 回答 1

1

怎么样,

    function updateThisIssueRow(thisRowsButton) {
        var issueIDInput, newPriorityInput, newAssignPersonInput, newIssueStatusInput, newIssueNotesInput;
        var $currentRow = $(thisRowsButton).closest('tr');
        issueIDInput = thisRowsButton.id;
        newPriorityInput = $currentRow.find('.priority').val();
        alert("Value of newPriorityInput is: " + newPriorityInput);

http://api.jquery.com/closest/

http://api.jquery.com/find/

于 2012-08-01T19:54:22.480 回答