0

This code should not generate any HTML button dynamically. Coz there is no div in the <html></html> section.

But it is generating one.

Why?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HtmlReWriting.aspx.cs" Inherits="JQuery_Intellisence_Test.HtmlReWriting" %>

<!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">
    <title></title> 
    <script src="Javascript/jquery-1.3.2.js" type="text/javascript">
        /// <reference path="Javascript/jquery-1.3.2-vsdoc.js" />
    </script>
    <script type="text/javascript">
        function ReWrite() {
            $('div').html('<input type="button" value="Button1" />');
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    </form>
    <input id="Button1" type="button" value="ReWrite HTML Element" onclick="ReWrite()" />
</body>
</html>

1 Answer 1

2

You are looking into an ASP.NET page. This generates an HTML page that actually contains some divs. The jQuery code runs on the generated HTML, not at the ASP.NET source.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes you are right. I didn't look at the generated client code.

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.