加载jquery弹出窗口时填充标签

时间:2015-04-20 12:22:20

标签: javascript jquery jquery-ui

将在我的项目中多次显示jquery弹出窗口。我想在每次使用不同的消息填充div中的标签,例如......

var popUpMessageSave = "You have successfully saved."; 
loadPopUp(popUpMessageSave);

var popUpMessageFail = "You have failed to save."; 
loadPopUp(popUpMessageFail);

不确定每次如何填充标签??

  <div style="display: none;">
        <div id="saveDialogSingleFeature" title="Save Complete">
            <input type="text" title="Name" value=""/>
            <label></label>
        </div>
    </div>

function loadPopUp(popUpMessage) {

    $("#saveDialogSingleFeature").dialog({
        width: "auto",
        height: "auto",
        position: { my: "top", at: "bottom", of: $("header") },
        show: { effect: "slideDown" },
        hide: true,
        closeOnEscape: true

    }).parent().appendTo("form:first");

    //clear label and add new 
    $('input:text').next('label').html("");
    $(this).next('label').html(popUpMessage);


    setTimeout(function () {
            $("#saveDialogSingleFeature").dialog('close')
            }, 5000);
}

更新 在DIV中添加了一个ID并添加为空并附加到loadPopUpMessage()

$("#popUpLabel").empty();
 $("#popUpLabel").append("some Text");

<input type="text" id="popUpLabel" value=""/>

0 个答案:

没有答案