Need help with converting JQuery to Javascipt.
Im trying to is, by clicking the 'Change Size' button result in a call to the new sizeObject.changeSize function and a change to both the Size object's isSize variable and the size of the light div in the browser
I dont want to change the HTML. Need help with converting the .click function
var sizeObject;
function createSize(){
//Size object initialisation
sizeObject = new Size();
// size-related event handlers
$('#change').click(function(){
Size.changeSize();
});
}
The regular Javascript function for binding event handlers is addEventListener
.
document.getElementById("change").addEventListener("click", function() {
sizeObject.changeSize();
});
Instead of :
$('#change').click(function(){
Size.changeSize();
});
Use :
var elem = document.getElementById("change");
elem.addEventListener("click", function() {
Size.changeSize();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.