开发者

how to call the javascript function on table row click

开发者 https://www.devze.com 2022-12-28 22:21 出处:网络
I have a javascript function.. <script type=\"text/javascript\"> var RowClick = function() { $(\"#mytable\").click(

I have a javascript function..

<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 class="something" onclick="javascript:RowClick()');">
can i call like this? if I call its not loading the URL?

can anybody help me out?

thanks


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

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

<tr class="something">


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

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

精彩评论

暂无评论...
验证码 换一张
取 消