I'm supposed to create a custom event triggered on page load that adds a class 'green' to the div with the id #myElementId. This is my attempt at the code but I'm getting an error message saying that I have to add the class green. Can you tell me what I'm doing wrong?
$(document).ready(function(){
$('#myElementId').bind('ready', function() {
$(this).addClass('green');
});
});
HTML
<body>
<div id="myElementId"></div>
</body>
Update
This is taken from a codecademy lesson that's supposed to teach me how to create a custom event that adds a class on page load, so even though there are other simpler solutions, I'm trying to solve it the way the lesson intended.
this is the hint they gave
$("#myElementId").on("myCustomEvent", function(event) {
});
divs don't haveonreadyevents.$('#myElementID').addClass('green')?