行のテキストに基づいて:私はjqueryのを使用することはできません状況にいることから、通常のjavascriptにSelect table row and check checkbox using JQueryJavascriptのチェックボックス私は、この変換しようとしています
を。ここで
のorignal
$("table tr").each(function() {
if ($(this).find("td:eq(1)").text().trim() == '2013-03-21') {
$(this).find("input[type=checkbox]").attr("checked", true);
}
});
これは私がこれまで持っているものである、と私はその方法オフ確信している:
var elements = [].slice.call(document.querySelectorAll("table tr"));
Array.prototype.forEach(elements, function(){
var tdText = this.querySelectorAll("td").textContent
if (tdText == '2013-03-21') {
this.querySelectorAll("input[type=checkbox]").setAttribute("checked", true);
}
});
これは元のテーブルです:
<table>
<tr>
<td>Record1</td>
<td>2013-03-21</td>
<td>
<input type="checkbox" />
</td>
</tr>
<tr>
<td>Record2</td>
<td>2013-03-22</td>
<td>
<input type="checkbox" />
</td>
</tr>
<tr>
<td>Record3</td>
<td>2013-03-21</td>
<td>
<input type="checkbox" />
</td>
</tr>
</table>
の
item
で慰め。 http://jsfiddle.net/Fdhyp/158/まだ動作していません。 – t67コードには問題がたくさんあります...試してみてくださいhttp://jsfiddle.net/Fdhyp/160/ – charlietfl
ありがとうございます。 – t67