如何在 jQuery 的对话框中显示标题



下面的代码用于在对话框中显示image, price, description。我想显示图片标题 在对话框标题栏中。我尽我所能,但没有运气。谁能帮我?

$(".dialogify").bind("click", function(e) {
    e.preventDefault();
    tit=$("#dialog").html("<img src='" + $(this).next().find('img').attr('title')+"'/>");
    $("#dialog").html("<img src='" + $(this).next().find('img').attr('src') + "' width='150' + height='150'>"+'<h2>'+ $(this).next().find('img').attr('title')+'</h2>'+"<label>"+ $(this).next().find('img').attr('price')+"</label>"+"<label>"+$(this).next().find('img').attr('desc')+"</label>"+"<input type='button' value='@(Model.ProductPrice.AvailableForPreOrder ? T("ShoppingCart.PreOrder") : T("ShoppingCart.AddToCart"))' class='button-2 product-box-add-to-cart-button' onclick='AjaxCart.addproducttocart('@addtocartlink '); return false;' />")
    $("#dialog").dialog("option", "position", {
        modal:"true",
        my: "center",
        at: "center",
        title:"tit",
        of: window
    });
    if ($("#dialog").dialog("isOpen") == false) {
        $("#dialog").dialog("open");
    }
});
您可以使用

类似option查看title

$("selector").dialog('option', 'title', 'New Title');

所以你使用以下代码

$("#dialog").dialog('option', 'title', $(this).next().find('img').attr('title'));

编辑

//Fetch title here
tit=$(this).next().find('img').attr('title');
$("#dialog").dialog("option", "position", {
    modal:"true",
    my: "center",
    at: "center",
    title: tit, //tit instead of 'tit'
    of: window
});

尝试:

title: tit

而不是:

title:"tit"
这个

怎么样

 $("#dialog").dialog( {
        modal:"true",
        my: "center",
        at: "center",
        title:"tit",
        of: window
    });

删除参数"选项","位置"

最新更新