Skip to content
Advertisement

Transfer to a separate js file

I am a noob in javascript, I need to hide a piece of code that I use in html in a separate js file and use it in several pages of the site, how can I do this?

This is the code that protects mail from spambots:

JavaScript

How can I transfer this code onmouseover="this.href=this.href.replace(/x/g,'');" to a separate js file and then use it here?

Advertisement

Answer

you can add a class to your email links

JavaScript

create a js file mouseover.js and add this code to it:

JavaScript

and add this file to every page that contains email links (can be more)

JavaScript

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement