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についてあまり知りません(したがって、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 に答える