Tuesday, April 2, 2013

Refresh div tag content


Below ASP.NET web form uses jquery to change the content inside a div tag.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#changePanel").click(function() {
    var data = "foobar";
    $("#panel").hide().html(data).fadeIn('fast');
    })
  });
    </script>
    <style type="text/css">
    div {
    padding: 1em;
    background-color: #00c000;
     }

    input {
    padding: .25em 1em;
     }​
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="panel">my data</div>
    <input id="changePanel" value="Change Panel" type="button"/>​
 
    </form>
</body>
</html>

No comments:
Write comments
Recommended Posts × +