如何将jQuery与母版页一起使用以更改<a> tag content on mouse enter?

时间:2015-11-25 10:22:36

标签: jquery asp.net

I want to change color of <a> tag content when mouse enters, but jQuery code is not working.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="mainpage.master.cs" Inherits="mainpage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>HOME</title>
    <script src="script/jquery-1.5.min.js" type="text/javascript"></script>
    <script>
        $(document).ready(function () {
            $("a").mouseenter(function () {
                $("a").css("background-color", "red");
            });
            $("a").mouseleave(function () {
                $("a").css("background-color", "darkgrey");
            });
        });

    </script>
    <asp:ContentPlaceHolder id="head" runat="server">


    </asp:ContentPlaceHolder>

</head>
<body style="margin:0px; padding:0px; margin-top:-20px">

        <header style="margin:0px">
            <div style="width:100%; height:190px; background-color:black;font-family:'Comic Sans MS' ">
          <img style="float:left; width:347px; height:150px; padding:10px" src="12074793_1484918625144001_4329591479695909380_n.png" /> 
               <%-- <h1 style="text-align:center; color:darkgreen"><i> Jump From <b>L</b> To <b>P</b> </i> </h1>--%>
                <h2 style="color:darkgreen; text-align:right;padding-right:15px; padding-top:15px" >+92-323-9494143 </h2>
                <h2 style="color:red; text-align:right;padding-right:15px;padding-top:15px"> amjadbukhari@hotmail.com </h2> 
            </div>
             <div style="width:100%;height:55px; background-color:darkgray; padding:2px;margin:0px"> <br />
  &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp   
                     <a href="home.aspx" style="text-decoration:none;color:black; border: 2px; border-radius:2px;background-color:darkgrey"> HOME</a>
 &nbsp  &nbsp &nbsp &nbsp &nbsp 
                  <a href="" style="text-decoration:none;color:black; border: 2px; border-radius:2px;background-color:darkgrey">ABOUT US</a>

             </div>
        </header>

        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>


</body>
</html>

Using the above code I want to change bgcolor of <a> to through jQuery, but it's not working.

Please help me in this how jQuery can be treated with master page I have tried no of times but its not working even this jQuery function works on simple HTML page but not here I have included library of jQuery to in folder where master page is present

0 个答案:

没有答案