2

This is my code in aspx page

<head runat="server">
<title></title>
<script src="//Scripts/jquery-1.4.1.js" type="text/javascript"> </script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#divGridView table tbody tr").mouseover(function () {
            $(this).addClass("highlightRow");
        }).mouseout(function () { $(this).removeClass('highlightRow'); })
    });       
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divGridView">
 <asp:GridView ID="gvOpenSII" runat="server">
 </asp:GridView>

When I run this code i get error: "Jquery runtime error: object expected".

I want to highlight the particular row in gridview on mouse hover.

Please help..

2 Answers 2

3

I would double check the script tag src attribute. Try

<script src="/Scripts/jquery-1.4.1.js" type="text/javascript"> </script>

or maybe

<script src="Scripts/jquery-1.4.1.js" type="text/javascript"> </script>
Sign up to request clarification or add additional context in comments.

2 Comments

code looks ok to me - could try a cdn to confirm that you can hit jquery - assuming you can get onto the url from your box ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.min.js. I would check the location of the script. Does a really simple jquery sample run i.e. alert($('body')); Or you could use the google cdn as this SO gives details. Here it was the script tag that was in error
Thank you so much..This was url issue only. I tried pick url option in visual studio and my new script tag look like <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
0

I'm not sure what html that is generating, but if it's not finding the element you're targeting that might cause the problem.

Try this instead, you'll have to adjust it a bit to suit your code, but it should work:

http://jsfiddle.net/will/8e2RQ/

$(function(){
    $('table tr').bind('mouseenter mouseleave',function(){
        $(this).toggleClass('highlightRow');
    });
});

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.