0
我有一些向div添加文本然後顯示它的代碼。如果不是已經可見,請顯示div
$("#messageBox").addClass('msg-error').text("Your selected date is no longer available due to the appointment duration. Please select an alternative date.").show();
然後我有一些其他的代碼,也將文本添加到相同的股利,並顯示它。
$("#messageBox").addClass('msg-error').text("Your selected time is no longer available due to the appointment duration. Please select an alternative time.").show();
但是,我只想要底部的消息顯示,如果messageBox div不可見。我的代碼是。
if($("#messageBox").not(':visible') || $("#messageBox").css("visibility") == "hidden"){
$("#messageBox").addClass('msg-error').text("Your selected time is no longer available due to the appointment duration. Please select an alternative time.").show();
}
它似乎並不總是工作,我做錯了什麼?
感謝