var RowClick = function() { $(...">

How to call javascript function on table row row

I have a javascript function.

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

Is it possible to call this function on an onclick event in tr? Am I 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?

thank

+5
source share
2 answers

There is no need to call RowClick()inline. Just put this code in the click event handler and attach it to each line:

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

<tr class="something">
+11
source

If I understand your question, you can do the following

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

All Articles