【发布时间】:2010-09-28 13:46:25
【问题描述】:
我目前正在使用一个函数来显示隐藏的 div.a_type
如何修改此代码,而不是在隐藏的 div 中淡出, 我可以将新的 div 添加到 DOM 中
jQuery(function(){ // 添加答案 jQuery(".add_answer").click(function(){ 如果(计数> =“4”){ alert('只允许 4 个答案'); }别的{ var count = $(this).attr("alt"); 计数++; $(this).parents('div:first').find('.a_type_'+count+'').fadeIn(); $(this).attr("alt", count); } }); });好的,既然我已经解决了这个问题,我还有一个问题,
如果单击按钮,我还有另一个功能可以删除插入的 div。 现在无法在页面加载时将其他 div 加载到 dom 中。 我现在如何触发删除这些功能?
jQuery(function(){ // 隐藏答案
jQuery(".destroy_answer").click(function(){
$(this).parents("div:first").fadeOut(function (){ $(this).remove() });
var count = $(this).parents('div:first').parents('div:first').find('.add_answer').attr("alt");
count--;
$(this).parents('div:first').parents('div:first').find('.add_answer').attr("alt", count);
});
});
【问题讨论】:
-
快速说明,虽然您可以打印 HTML,但您不能通过 javascript 打印 PHP,因为 PHP 是一个预处理器。
-
很高兴知道...您如何建议我在我要打印的选择中打印 php 会话数据?
-
使用 AJAX 获取 php 会话数据(jQuery 有 AJAX 工具,我将更新我的分析器以使用它们。
标签: javascript jquery dom