在jQuery中插入后更新DOM

假设我使用jQuery将新内容加载到特定的DIV元素中.如果我现在想从DIV元素中捕获事件,我认为DOM必须以某种方式更新?处理这个问题的最佳方法是什么?

编辑:这是我的意思的一个例子:

<html>
  <head>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script>
      $(document).ready(function(){
        $(".edit").click(function(){
          $(this).parent().load("edit");
        });
        $(".view").click(function(){
          $(this).parent().load("view");
        });
      });
    </script>
  </head>
  <body>
    <div class='someid'>
      <input type='submit' class='edit' value='Edit'>
    </div>
  </body>
</html>

同一级别的文件编辑包含的位置

<input type='submit' class='view' value='View'>

一个文件’view’包含

<input type='submit' class='edit' value='Edit'>

如果你试试这个,你会看到当你第一次按下编辑时,按钮变为视图,但它不会再改变.为什么是这样?

解决方法

像这样使用 live
$(".view").live("click",function(){
      $(this).parent().load("view");
    });

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...