jquery this row find class

 

1.利用easyui datagrid, 找到選取哪一列 index

 var rowIndex = $("#tasks-datagrid").datagrid("getRowIndex", selectedrow);

2. jquery 去find 該列 index 的 class

var rowClass = $("#example tbody tr:eq(" + row.index() + ")").attr('class');
var hasOddClass = $(row.node).hasClass("odd");

https://stackoverflow.com/questions/28907260/how-can-i-get-a-class-from-a-jquery-datatable-row-object
======

https://www.jeasyui.com/forum/index.php?topic=206.0


https://stackoverflow.com/questions/11275092/jquery-table-selected-row

===

https://api.jquery.com/eq-selector/

====

var tdListUser = $("table>tbody>tr").find("td:eq(3)"); // 获取第四列的数据

====

<script>
    $(function() {
      $('#userTable').on('click''tbody tr'function(event) {
        $(this).addClass('highlight').siblings().removeClass('highlight');
      });

      $('#btnRowClick').click(function(e) {
        var rows = getHighlightRow();
        if (rows != undefined) {
          alert(rows.attr('id'));
        }
      });

      var getHighlightRow = function() {
        return $('table > tbody > tr.highlight');
      }

    });
  </script>
</head>

<body>
  <div>
    <h2>How to find selected row using jQuery?</h2>
  </div>
  <button id="btnRowClick" class="button">Get Selected Row Ids</button><br/>
  <table id="userTable" class="row">
    <tbody>
      <tr style="background-color: #F0F8FF;">
        <th><b>Id</b></th>
        <th><b>Name</b></th>
        <th><b>Age</b></th>
      </tr>
      <tr id="row1">
        <td>1</td>
        <td>Anil</td>
        <td>30</td>
      </tr>

http://embed.plnkr.co/DCS0Mt/preview

====

https://stackoverflow.com/questions/5346084/how-to-select-all-table-rows-tr-that-contained-a-class-jquery/5346116 


$('#mytable tr').each(function() {

    var customerId = $(this).find("td:first").html();    
});

$('#mytable tr').each(function() {
    var customerId = $(this).find("td").eq(2).html();    
});
====

Here's how you can do it without jQuery:

var table = document.getElementById('mytable'), 
    rows = table.getElementsByTagName('tr'),
    i, j, cells, customerId;

for (i = 0, j = rows.length; i < j; ++i) {
    cells = rows[i].getElementsByTagName('td');
    if (!cells.length) {
        continue;
    }
    customerId = cells[0].innerHTML;
}

https://www.blogger.com/blog/post/edit/1773852665161105995/1801061706573802254


=========
 
I have a table (#tbLog) and need to select all table rows (tr) that contain a class called private.

$('.private')
$("#tbLog tr.private").action();

$('#tbLog tr.private')


$("#tbLog").children("tr .private")

f you have sub tables (why?), then use this instead to only select the top level trs

$("#tbLog > tbody > tr.private").action();

====
$("tr.concept2");

https://stackoverflow.com/questions/7226381/how-to-select-a-row-with-particular-class-name-in-jquery

留言

這個網誌中的熱門文章

考績被打差了 輕率離職會更傷

Arrays - DS (Reverse array) [Easy]

WireMock