如何从下面给定的html表格中获得鼠标点击或checking the checkbox preferably
的行值?如何在鼠标点击事件中从动态表格中选择一行
这里是js
使用从XML获取值我的表轻快
var ds1 = new Spry.Data.XMLDataSet("xml/data.xml", "rows/row");
var pv1 = new Spry.Data.PagedView(ds1 ,{ pageSize: 10 , forceFullPages:true, useZeroBasedIndexes:true});
var pvInfo = pv1.getPagingInfo();
这里是包含被从pv1
填充表(见JS部分)
<div id="configDiv" name="config" style="width:100%;" spry:region="pv1">
<div spry:state="loading">Loading - Please stand by...</div>
<div spry:state="error">Oh crap, something went wrong!</div>
<div spry:state="ready">
<table id="tableDg" onclick="runEffect('Highlight', 'trEven', {duration: 1000, from: '#000000', to: '#805600', restoreColor: '#805600', toggle:true}, 'Flashes a color as the background of an HTML element.')"
style="border:#2F5882 1px solid;width:100%;" cellspacing="1" cellpadding="1">
<thead>
<tr id="trHead" style="color :#FFFFFF;background-color: #8EA4BB">
<th width="2%"><input id="chkbHead" type='checkbox' /></th>
<th width="10%" align="center" spry:sort="name"><b>Name</b></th>
<th width="22%" align="center" spry:sort="email"><b>Email</b></th>
</tr>
</thead>
<tbody spry:repeat="pv1">
<tr class="trOdd"
spry:if="({ds_RowNumber} % 2) != 0" onclick="ds1.setCurrentRow('{ds_RowID}');"
style="color :#2F5882;background-color: #FFFFFF">
<td><input type="checkbox" id="chkbTest" class = "chkbCsm"></input></td>
<td width="10%" align="center"> {name}</td>
<td width="22%" align="center"> {email}</td>
</tr>
<tr class="trEven" name="trEven" id="trEven"
spry:if="({ds_RowNumber} % 2) == 0" onclick="ds1.setCurrentRow('{ds_RowID}');"
style="color :#2F5882;background-color: #EDF1F5;">
<td><input type="checkbox" class = "chkbCsm"></input></td>
<td id="tdname" width="10%" align="center"> {name}</td>
<td width="22%" align="center"> {email}</td>
</tr>
</tbody>
</table>
</div>
</div>
的
Div
与
spry
区
我想下面的代码,但仍然没有得到警报,因此没有答案也无法正常工作。我知道所有的语法都是正确的,但我无法弄清楚这里有什么问题!
//inside $(document).ready(function()
$("#chkbHead").click(function() {
alert("Hi");
});
我的页面也有其他表格用于对齐一些内容。因此,当我使用下面的代码时,它完美地工作在那些除了问题中的表之外的表上。这可能是问题,因为表中只有2 tr
被spry数据集填充,因此无法正确识别。可能是,我不知道,只是试图帮助提高我的理解
$('tr').click(function() {
alert("by");
});
通过'value'我指的是元素特定行的值,例如'input type =“复选框”选中或未选中“,”特定行“的”名称“和”email“ – abi1964 2011-05-12 08:34:12
我已经向您展示了如何在最后一个代码片段中执行该操作 - 文本的价值框嵌套在一个表行 - 我将编辑我的答案,以显示如何检查复选框这种方式 – jcvandan 2011-05-12 08:37:55
@dormisher:我试过你的解决方案,但没有发生,似乎答案是正确的。请阅读我编辑的问题。 – abi1964 2011-05-12 09:02:13