Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6841321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:57:07+00:00 2026-05-26T23:57:07+00:00

I want to highlight my elements and add a link with jquery. My Code:

  • 0

I want to highlight my elements and add a link with jquery.

My Code:

@model IEnumerable<Mvc3Demo.Products>

@{
    ViewBag.Title = "List";
}

<h2>List</h2>
<script type="text/javascript" src="../../Scripts/jquery-1.5.1.min.js" />
<script type="text/javascript">
    $(document).ready(function () {
        $('#productList li').hover(
            function () {
                $(this).css({ 'background': 'green', 'cursor': 'pointer' });
            },
            function () {
                $(this).css('background', '');
            }
        ).click(function () {
            window.location = 'Product/Edit/' + $(this).attr('productid');
        });
    });
</script>

<ul id="productList">
@foreach (Mvc3Demo.Products p in Model)
{
    <li productid="@p.ProductsID">
        @p.Name
        <!--@Html.ActionLink("Bearbeiten", "Edit", "Product", p, null)-->
    </li>
}
</ul>

Layout page:

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
</head>

<body>
    @RenderBody()
</body>
</html>

The JQuery will be found so that couldn’t be the error ( i proofed it with firebug)

Error:

No Error occurs in Firebug and no highlighting and no link

Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:57:07+00:00Added an answer on May 26, 2026 at 11:57 pm

    Don’t you have something in your Layout page that broke the jQuery functionality?
    Try to unbind your page from the Layout and test it indipendently.
    Or post your Layout page to let us see what could be wrong with it…

    Edited after seeing the Layout page:

    There’s the error. you already have the jquery reference in the layout page. This cause the error. Simply delete the reference from you page leaving the one in the layout) and everything is going to work.
    I created a littel project to test it.

    PS: I still don’t understand why 2 references to the same javascritp file cause the error :/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to link to bookmark on a page (mysite.com/mypage.htm#bookmark) AND visually highlight the
I'm trying to find a Java library to highlight code. I don't want to
I have the following XML <title> This is a <highlight>test</highlight> thanks. </title> and want
I'm using jQuery.append() to add some elements dynamically. Is there any way to get
I want to highlight C/C++/Java/C# etc source codes in my website. How can I
I have a table that i want to highlight during onmouseover/onmouseout. I already know
When comparing similar lines, I want to highlight the differences on the same line:
I have a longer text and some keywords. I want to highlight these keywords
I want to make a uiview that can be aware of highlight status, like
I'm trying to highlight the search results but I want to include the surrounding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.