表包含2列。每一列都有表格元素,如文本框和下拉框。我想要的是,当我单击行时,我必须调用javascript函数。我的问题是,当我在文本框中输入值或从下拉列表中选择值时,javascript函数也调用了。如何防止这件事。当输入文本框并从下拉列表中选择值时,我不想触发javascript函数。
jQuery("#testParam tbody tr").on("click", function(event) {
var position = paramTable.fnGetPosition(this); // getting the clicked row position
//alert(position);
createTable();
});
function createTable(){
alert("clicked");
}
<table id="testParam">
<thead>
<tr>
<th class="no-sort">
Name
</th>
<th class="no-sort">
Type
</th>
</tr>
</thead>
<tbody>
<tr id="paramRow1">
<td><g:textField name="name1" id="name1" required="" value="${testName}" /></td>
<td><g:select name="type1" noSelection="['':'-Select-']"
id="type1"
from="${testParameterInstance?.constraints?.type?.inList}"
required="" value="${testParameterInstance?.type}"
valueMessagePrefix="testParameter.type" /></td>
</tr>
</tbody>
</table>发布于 2014-04-03 11:23:35
试试这边
$('#name1,#type1').on('click',function(event){
event.stopPropagation();
});快乐编码:)
https://stackoverflow.com/questions/22833004
复制相似问题