问题描述
动态加载的元素上click事件不生效
$(".openORclose2").click(function () {
if ($(this).hasClass("checkOpen2")) {
$(this).removeClass("checkOpen2");
$(this).parent().parent().removeClass("QAhover");
$(this).parent().parent().find(".Answer").slideUp();
} else {
原因分析:
元素没有绑定上click事件
解决方案:
$().live适用于当前及未来元素
$(".openORclose2").live("click",function () {
if ($(this).hasClass("checkOpen2")) {
$(this).removeClass("checkOpen2");
$(this).parent().parent().removeClass("QAhover");
$(this).parent().parent().find(".Answer").slideUp();
} else {