t 我已经尝试解决这个问题两天了,我快疯了,请大家帮忙。我正在尝试在锚点内附加一个新的 div(插入 html 代码),看起来还可以,但链接不起作用。我正在尝试使用 class='delete' 来调用另一个 jquery 函数来删除新的 div 元素。这个想法是一个购物车,我添加了一个产品,添加后我想删除,但它不起作用。这是我的代码:
$("#dialog-form").dialog({
autoOpen: false,
height: 320,
width: 320,
modal: true,
show: 'slide',
buttons: {
"Agregar Tour": function () {
var bValid = true;
allFields.removeClass("ui-state-error");
bValid = bValid && checkLength(adl, "Adultos", 1, 5);
bValid = bValid && checkLength(chls, "Niños", 0, 5);
bValid = bValid && checkLength(fecha, "Fecha", 1, 16);
var id = $(this).val("id");
var string = 'tourid=' + tourid;
//var tourid = '<?php echo $moneda ?>';
//alert(tourid);
if (bValid) {
$.ajax({
url: "add_item.php",
data: "tourid=" + tourid + "&adl=" + adl.val() + "&chl=" + chls.val() + "&fecha=" + fecha + "",
dataType: 'json',
type: "GET",
cache: false,
success: function (data) {
var regis = data[0];
var titulo = data[6];
var desc = data[7];
var total = data[12];
var foto = data[15];
var items = data[21];
var ruta = "images/hoteles/" + foto + "";
$("#containerx").append("<div id='containerx' class='koko' ><b><font color='#3399CC'>" + titulo + "</font></b><br>" + desc + "<br>" + "<b><font color='#ff0099'>Sub-total </font></b><image src='images/arrow.gif'> $" + total + " MXP " + "<a href='#' id=" + regis + " class='delele'>" + "<image src='images/delete.gif'></a></div><div style='clear:both;'></div>");
$("#containerx.koko").fadeTo(1000, 0.7);
$("#dialog-message").dialog({
modal: true,
show: 'slide',
buttons: {
Ok: function () {
$(this).dialog("close");
}
}
});
$("#items").html("<div id='items'>[" + items + "]</div>");
$('#load').fadeOut();
}
});
$(this).dialog("close");
}
},
Cancel: function () {
$(this).dialog("close");
}
},
close: function () {
allFields.val("").removeClass("ui-state-error");
}
});
$(".add-item").button().click(function () {
tourid = $(this).attr("id");
$("#dialog-form").dialog("open");
});