插入jQuery中后更新DOM [英] Update DOM after insert in jQuery
本文介绍了插入jQuery中后更新DOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我使用jQuery加载新的内容到一个特定的DIV元素。如果我现在想从DIV元素内赶上的事件,我假定DOM有以某种方式更新?什么是解决这一问题的最佳方法是什么?
Let's say I use jQuery to load new content into a specific DIV element. If I now want to catch events from inside that DIV element, I assume the DOM has to be updated somehow? What is the best way to deal with this?
编辑:这是我的意思的例子:
Here is an example of what I mean:
<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>
其中一个文件修改
在同级别中包含
where a file edit
at the same level contains
<input type='submit' class='view' value='View'>
和文件视图包含
<input type='submit' class='edit' value='Edit'>
如果您尝试了这一点,你会看到,当你第一次preSS编辑,该按钮更改查看,但它不会再改变。这是为什么?
If you try this out you will see that when you first press Edit, the button changes to View, but then it doesn't change anymore. Why is this?
推荐答案
使用住是这样的:
$(".view").live("click",function(){
$(this).parent().load("view");
});
这篇关于插入jQuery中后更新DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文