Link to home
Start Free TrialLog in
Avatar of KaranGupta
KaranGupta

asked on

Issue in code

Hi

What is the issue in the code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Write_Output_Write.aspx.cs"
    Inherits="Write_Output_Write" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <%--<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />--%>
    <title></title>

    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        $(document).ready(
            function() {
                $("ul#websiteList li a").click(
                    function($e) {
                        alert("Hello");
                    }
                );
            }
        );
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ul id="websiteList">
        <li><a href="http://www.google.com">google</a></li>
    </ul>
    <ul>
        <li><a href="http://www.rediff.com">Rediff</a></li>
    </ul>
    </form>
</body>
</html>

Open in new window


When I click on the link message box is not coming.

Regards
Karan Gupta
ASKER CERTIFIED SOLUTION
Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
With your code
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

<script>

  
  
</script>
</head>

<body>
 <ul id="websiteList">
        <li><a href="http://www.google.com">google</a></li>
    </ul>
    <ul>
        <li><a href="http://www.rediff.com">Rediff</a></li>
    </ul>
  
</body>

</html>


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Write_Output_Write.aspx.cs"
    Inherits="Write_Output_Write" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <%--<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />--%>
    <title></title>

    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
      $(document).ready(function(){
  
          $("ul#websiteList li a").click(
                    function($e) {
                        alert("Hello");
                    }
                );    
  
   
  });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ul id="websiteList">
        <li><a href="http://www.google.com">google</a></li>
    </ul>
    <ul>
        <li><a href="http://www.rediff.com">Rediff</a></li>
    </ul>
    </form>
</body>
</html>

Open in new window

Avatar of KaranGupta
KaranGupta

ASKER

HI sonawanekiran

I don't see any difference in the code. What is the difference in the code? I have executed both the codes and is not working.

Regards
Karan Gupta
Yes. Both of our code is correct. Sorry I haven't checked your code. Do you want to show the alert when you click on Rediff also?
Below link is domo for your script

http://jsfiddle.net/TpSZG/2/

When you click on google it shows the alert "Hello"
Try either of the below

<body>
 <ul id="websiteList">
        <li><a href="http://www.google.com">google</a></li>
        <li><a href="http://www.rediff.com">Rediff</a></li>
    </ul>
</body>

or

<body>
 <ul id="websiteList">
        <li><a href="http://www.google.com">google</a></li>
    </ul>
    <ul id="websiteList">
        <li><a href="http://www.rediff.com">Rediff</a></li>
    </ul>
</body>