It seems like this is the information you have been given.
var element = document.querySelector(".clickable-element");
element.addEventListener("click", (e) => {
e.preventDefault();
//perform desired actions here
console.log("redirect to a different website");
});
<a href="http://www.example.com" class="clickable-element">Example</a>
The approach mentioned above can result in cluttered code that is challenging to comprehend and maintain. It is advisable to separate HTML, CSS, and JS code to improve readability and organization. To prevent conflicts between your JavaScript and styling when making modifications, it is recommended to assign distinct classes for functionality and design purposes.
For instance, using the class "clickable-element" solely for JavaScript functionalities, while applying a different class for styling purposes. This segregation ensures better manageability and prevents unintended impacts on your codebase.