Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call the javascript function on table row click

Tags:

jquery

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

like image 397
kumar Avatar asked May 04 '10 16:05

kumar


People also ask

What is onrowclick () function in JavaScript?

The javascript function that adds on click event on each row in the table. The function takes the table id as the parameter and return a callback with the row object on each row when it is clicked. function onRowClick(tableId, callback) { var table = document.getElementById(tableId),

How to add click event on each row in an HTML table?

The html table. The javascript function that adds on click event on each row in the table. The function takes the table id as the parameter and return a callback with the row object on each row when it is clicked. document.getElementById ('click-response').innerHTML = value + " clicked!";

How to call function on button click in JavaScript?

How to Call Function on Button Click in JavaScript? There are two methods to call a function on button click in JavaScript. They are Get the reference to the button. For example, using getElementById () method.

How to get the row object on click response in HTML?

The function takes the table id as the parameter and return a callback with the row object on each row when it is clicked. document.getElementById ('click-response').innerHTML = value + " clicked!";


1 Answers

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">
like image 133
karim79 Avatar answered Sep 27 '22 20:09

karim79