How to Change Attribute Value by Java Script on Window Load in Pega?

Share with Love

You can change the value of an attribute in JavaScript when the page is finished loading by using the window.onload event. Here’s an example that changes the value of an attribute called data-example for an element with an ID of “element_id”:

javascript
window.onload = function() {
document.getElementById(“element_id”).setAttribute(“data-example”, “new_value”);
};

The window.onload event is fired when all of the resources for a page have finished loading, including images, scripts, and stylesheets. This ensures that the element with the specified ID is available in the DOM and can be manipulated by JavaScript.

By Admin

Sam is the founder and editor of TheGuestBlogging.com. With over 10 years of experience in website development, WordPress, SEO, and digital marketing, he helps businesses, bloggers, and website owners grow their online presence through content marketing and search engine optimization. I regularly writes about blogging, guest posting, technology, entertainment, and online business trends. My goal is to provide accurate, helpful, and up-to-date information that helps readers make informed decisions.

View All Posts