<div id="listWrapper">
<table cellpadding="0" cellspacing="0" id="list" class="ig_DarkBlue7Item iggWG_DarkBlue7Item tableLineHeight">
<tbody>
<tr>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="UstKriterDegeri">
<span role="button" class="filtreButtonUKD"><img src="Icon/filtre.gif"></span>ÜST KRİTER DEĞERİ
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="Isim">
<span role="button" class="filtreButtonI"><img src="Icon/filtre.gif"></span>İSİM
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="KolayKod">
<span role="button" class="filtreButtonKK"><img src="Icon/filtre.gif"></span>KOLAY KOD
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="AsilDeğer">
<span role="button" class="filtreButtonAD"><img src="Icon/filtre.gif"></span>ASIL DEĞER
</td>
</tr>
<tr class="item iggWG_DarkBlue7ActiveRow"><td><span class="ig_DarkBlue7Item">20</span><input type="hidden" name="LNGSAKLAMABASLIK" value="1"></td><td>Kat4</td><td>10</td><td>522</td></tr>
<tr class="item iggWG_DarkBlue7RowOdd"><td><span class="ig_DarkBlue7Item">21</span><input type="hidden" name="LNGSAKLAMABASLIK" value="2"></td><td>Kat5</td><td>11</td><td>523</td></tr>
<tr class="item"><td><span class="ig_DarkBlue7Item">22</span><input type="hidden" name="LNGSAKLAMABASLIK" value="3"></td><td>Kat4</td><td>152</td><td>546</td></tr>
</tbody>
</table>
iggWG_DarkBlue7ActiveRow类是我选择的行。 我想从所选行的隐藏中获取价值。 jQuery的代码是什么。
var secilenId = $('tr.iggWG_DarkBlue7ActiveRow td input:hidden[name="LNGSAKLAMABASLIK"]').val();
我已经尝试过了,但是没有用。
答案 0 :(得分:0)
jQuery和本机JS DOM选择均有效:
console.log("native js logs " + document.querySelector('.iggWG_DarkBlue7ActiveRow input[type=hidden][name=LNGSAKLAMABASLIK]').value)
console.log("jquery logs " + $('tr.iggWG_DarkBlue7ActiveRow td input:hidden[name="LNGSAKLAMABASLIK"]').val())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table cellpadding="0" cellspacing="0" id="list" class="ig_DarkBlue7Item iggWG_DarkBlue7Item tableLineHeight">
<tbody>
<tr>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="UstKriterDegeri">
<span role="button" class="filtreButtonUKD"><img src="Icon/filtre.gif"></span>ÜST KRİTER DEĞERİ
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="Isim">
<span role="button" class="filtreButtonI"><img src="Icon/filtre.gif"></span>İSİM
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="KolayKod">
<span role="button" class="filtreButtonKK"><img src="Icon/filtre.gif"></span>KOLAY KOD
</td>
<td id="listHeader" class="igg_DarkBlue7HeaderCaption iggWG_DarkBlue7HeaderCaption" colkey="AsilDeğer">
<span role="button" class="filtreButtonAD"><img src="Icon/filtre.gif"></span>ASIL DEĞER
</td>
</tr>
<tr class="item iggWG_DarkBlue7ActiveRow"><td><span class="ig_DarkBlue7Item">20</span><input type="hidden" name="LNGSAKLAMABASLIK" value="1"></td><td>Kat4</td><td>10</td><td>522</td></tr>
<tr class="item iggWG_DarkBlue7RowOdd"><td><span class="ig_DarkBlue7Item">21</span><input type="hidden" name="LNGSAKLAMABASLIK" value="2"></td><td>Kat5</td><td>11</td><td>523</td></tr>
<tr class="item"><td><span class="ig_DarkBlue7Item">22</span><input type="hidden" name="LNGSAKLAMABASLIK" value="3"></td><td>Kat4</td><td>152</td><td>546</td></tr>
</tbody>
</table>
答案 1 :(得分:0)
使用jquery,您可以尝试
var secilenId = $('tr.iggWG_DarkBlue7ActiveRow td input:hidden[name="LNGSAKLAMABASLIK"]').getAttribute('value')
答案 2 :(得分:0)
这是我的行选择代码:
$('tr').on('click', function () {
$('tr').removeClass('iggWG_DarkBlue7ActiveRow');
if ($(this).hasClass('item')) {
$(this).addClass('iggWG_DarkBlue7ActiveRow');
}
});
而我的触发按钮在另一个表中
当我单击以获取隐藏值时,所选的行类正在运行
然后我将这段代码转换为:
$('tr.item').on('click', function () {
$('tr').removeClass('iggWG_DarkBlue7ActiveRow');
if ($(this).hasClass('item')) {
$(this).addClass('iggWG_DarkBlue7ActiveRow');
}
});
在我的onclick选择器中添加了“ item”类