我有这些
<div id="shelf">
<div>
<input type="text" id="new-shelf-text" onkeyup="(this.value).trim().length?$('#add-shelf-btn').removeClass('disabled'):$('#add-shelf-btn').addClass('disabled');" placeholder="Add new shelf">
</div>
<div>
<div id="add-shelf-btn" class="button postfix disabled">Add</div>
</div>
<a class="shelfName" href="#shelF"> Shelf Lists </a>
<div id="shelF" class="content">
welcome in shelf listing
</div>
</div>
<script>
$("#add-shelf-btn").click(function() {
$.ajax({
type: "POST",
url: "{% url 'shelf' groupid %}",
datatype: "html",
data:{
shelf_name: $('#new-shelf-text').val(),
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function(data) {
$("#shelf").html(data);
}
});
});
</script>
当我在成功ajax返回后点击上面提到的链接(锚标签)时它不会调用id为“shelF”的“div” 任何人都可以帮助我,我想打电话给
<div id="shelF" class="content">
点击链接
<a class="shelfName" href="#shelF"> Shelf Lists </a>
记住它第一次工作正常,但是当它从successl ajax调用返回时,div不会被调用。
答案 0 :(得分:0)
尝试将此用作触发器:
$(document).on("click", "#add-shelf-btn", function() {code...})