首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Datatable的行单击调用javascript函数使用JQuery

问Datatable的行单击调用javascript函数使用JQuery
EN

Stack Overflow用户
提问于 2014-04-03 09:14:03
回答 1查看 2.1K关注 0票数 0

表包含2列。每一列都有表格元素,如文本框和下拉框。我想要的是,当我单击行时,我必须调用javascript函数。我的问题是,当我在文本框中输入值或从下拉列表中选择值时,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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-03 11:23:35

试试这边

代码语言:javascript
复制
$('#name1,#type1').on('click',function(event){
    event.stopPropagation();
});

快乐编码:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22833004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档