события в элементе
Подскажите пожалуйста,
как задать CustomEvent() или new Event() что-бы использовать в html коде или setAttribute() нпример
var event = new Event('build');
function View()
{
var i = document.createElement('div');
i.textContent = String.fromCharCode(10004)
//задам функцию для события известным способом
// i.addEventListener('build', function (e) { alert() }, false);
//а надо задать событие в setAttribute
i.setAttribute(event, 'new Function'); // -как это сделать
i.Function = function() { alert() }
return i
}
document.body.appendChild(View())
или <div id='x' event='alert|()'></div> |
var event = new Event('build');
function View()
{
var i = document.createElement('div');
i.textContent = String.fromCharCode(10004)
i.setAttribute('build', 'new Function');
i.Function = function() { alert() }
return i
}
document.body.appendChild(View())
|
| Часовой пояс GMT +3, время: 09:17. |