<a href="example.com" class="a">
I would like to add an onclick event using regular expressions to a tag like the one above.
How will it work?
Please let me know if you know more.Thank you for your cooperation.
It's not a regular expression, but if you use the querySelectorAll function, it looks like this.
function someFunction(event){
console.log(event);
}
varaList= document.querySelectorAll('a.a');
for (vari=0;i<aList.length;i++) {
aList[i].onclick=someFunction;
}
<a href="example.com" class="a">example.com</a>
<a href="sub.example.com" class="a">sub.example.com</a>
545 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
540 Unable to install versioned in Google Colab
545 Understanding How to Configure Google API Key
683 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
525 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.