为什么弹出时不会更改第二个jQuery-UI对话框标题.第一个对话框我使用以下.attr("title", "Confirm")内容更改了框的标题 - 它将第一个框的标题更改为"确认",就像它应该具有的那样.现在,当弹出第二个框时,它应该将标题更改为"消息",因为对第二个框执行相同的操作 - .attr("title", "Message").对?但它没有.它保留了之前的标题.但是,消息会像它应该的那样改变.我已经在IE8,Chrome和FF3.6中进行了测试.
<div id="dialog-confirm" title=""></div> < - 这是jQuery函数之前的html.
$('#userDelete').click(function() {
$(function() {
var dialogIcon = "<span class=\"ui-icon ui-icon-alert\"></span>";
var dialogMessage = dialogIcon + "Are you sure you want to delete?";
$("#dialog-confirm").attr("title", "Confirm").html(dialogMessage).dialog({
resizable: false,
height: 125,
width: 300,
modal: true,
buttons: {
'Delete': function() {
$(this).dialog('close');
$.post('user_ajax.php', {action: 'delete',
aId: $('[name=aId]').val()
}, function(data) {
if(data.success){
var dialogIcon = "<span class=\"ui-icon ui-icon-info\"></span>";
var dialogMessage = dialogIcon + data.message;
$('#dialog-confirm').attr("title", "Message");
$('#dialog-confirm').html(dialogMessage);
$('#dialog-confirm').dialog({ …Run Code Online (Sandbox Code Playgroud) 码:
function SnakeGame() {
"use strict";
/***** Constant & Global Variables ***********************************/
var canvas = $("#canvas")[0];
var ctx = canvas.getContext('2d');
var width = $("#canvas").width();
var height = $("#canvas").height();
var snake, food;
function Snake() {
var startLength = 5; // default for starting size of snake
this.body = [];
this.chgStartLength = function(length) {
startLength = length;
};
this.create = function() {
var i;
for(i=0; i>5; i++) {
this.body.push({x:i, y:0});
}
};
}
var paintCanvas = function() {
ctx.fillStyle = 'white';
ctx.fillRect(0, …Run Code Online (Sandbox Code Playgroud)