如何调用表行上的javascript函数

时间:2023-01-04 17:33:43

I have a javascript function..

我有一个javascript函数。

<script type="text/javascript">
    var RowClick = function() {
        $("#mytable").click(
        $("#showgrid").load('/Products/List/Items/'));
    };
</script>

Can I call this function on onclick event on tr? I am calling something like this?

我可以在tr上的onclick事件上调用这个函数吗?我打电话是这样的吗?

<tr class="something" onclick="javascript:RowClick()');">
can i call like this? if I call its not loading the URL?

can anybody help me out?

谁能帮我一下吗?

thanks

谢谢

2 个解决方案

#1


11  

There is no need to call RowClick() inline. Just put that code into a click event handler and attach it to each row:

不需要调用RowClick()内联。只需将代码放入单击事件处理程序中,并将其附加到每一行:

$(document).ready(function() {
    $("#mytable tr.something").click(function() {
        $("#showgrid").load('/Products/List/Items/'));
    });
});

<tr class="something">

#2


0  

If I've understood your question you can do the following

如果我理解了你的问题,你可以做以下的事情

$("tr").click(function () {
  //call funcion
});

#1


11  

There is no need to call RowClick() inline. Just put that code into a click event handler and attach it to each row:

不需要调用RowClick()内联。只需将代码放入单击事件处理程序中,并将其附加到每一行:

$(document).ready(function() {
    $("#mytable tr.something").click(function() {
        $("#showgrid").load('/Products/List/Items/'));
    });
});

<tr class="something">

#2


0  

If I've understood your question you can do the following

如果我理解了你的问题,你可以做以下的事情

$("tr").click(function () {
  //call funcion
});