5

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

2
  • You might also want to take a look here at how to add visual cues to indicate that a row or cell is clickable radio.javaranch.com/pascarello/2004/12/30/1104419159000.html Commented May 4, 2010 at 16:16
  • 1
    the "javascript:" protocol in your onclick handler is redundant.. just call onclick="RowClick();" Commented May 4, 2010 at 16:35

2 Answers 2

11

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">
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.