document.addEventListener('DOMContentLoaded', function() {
// Вешаем событие при нажатии на Show
var Show = document.getElementsByClassName('button-light');
[].forEach.call(Show, function(element, i) {
element.addEventListener('click', function(){
showMessageDialog(i);
});
});
// Вешаем событие при нажатии на Ok
var Close = document.getElementsByClassName('button-primary');
[].forEach.call(Close, function(element, i) {
element.addEventListener('click', function(){
closeMessageDialog(i);
});
});
});
function showMessageDialog(i){
var modal = document.getElementsByClassName('ui-message-box__wrapper')[i];
modal.style.display = "block";
}
function closeMessageDialog(i){
var modal = document.getElementsByClassName('ui-message-box__wrapper')[i];
modal.style.display = "none";
}
您的页面不应包含具有相同 ID 的元素。你的代码没有解析,我画了自己的版本,你可以这样。