0
首先,我乘用javascript div和之後的功能無法正常工作JavaScript的工作不
function setDoorCount(count) {
$('.doors').html('');
for (var i = 0; i < count; i++) {
var content = "<div class='door' data-door='" + i + "'><img id='door-id-" + i + "' src='' /></div>";
$('.doors').append(content);
}
}
之後,試圖打開對話框,並不能正常工作,因爲它應該
var selectedDoorId = 0;
var openDialog = function() {
selectedDoorId = $(this).attr('data-door');
$('.dialog-button').click(function() {
var color = $(this).attr('id');
document.getElementById('door-id-' + selectedDoorId).src = 'http://www.#.asd' + color + '.png';
$('#door-panel-color').dialog('close');
});
$('#door-panel-color').dialog('open');
}
$(function() {
$("#door-panel-color").dialog({
autoOpen: false,
minHeight: 'auto',
width: 650,
modal: true,
open: function(){
$('.ui-widget-overlay').bind('click',function(){
$('#door-panel-color').dialog('close');
})
}
})
$('.door').click(openDialog);
});
HTML:
<div class="doors">
<div class="door" data-door="0">
<img class="door-color" id="door-id-0" src="http://liukuovitukku.fi/images/door-colors/pahkina.png" />
</div>
</div>
你可以在這裏添加你所有的html代碼。 –
http://pastebin.com/YeLp0bXT – Hene