HTML ::
<input type="button" value="Click me !!" id="btn" onClick="customFun()" />JavaScript ::
var el = document.getElementById("btn");
var evt = document.createEvent('Event');
evt.initEvent('build', true, true);
// Function to change the content of t2
function modifyText() {
alert("Hi");
}
// add event listener to t
el.addEventListener("build", modifyText, false);
$('#btn').click(function(){
alert("Hello");
el.dispatchEvent(evt);
});
var evt = document.createEvent('Event');
evt.initEvent('build', true, true);
// Function to change the content of t2
function modifyText() {
alert("Hi");
}
// add event listener to t
el.addEventListener("build", modifyText, false);
$('#btn').click(function(){
alert("Hello");
el.dispatchEvent(evt);
});
No comments:
Post a Comment