after an hour of trial and error with the creation of a simple script, I'm asking you for help. I would like to create a button
, which after clicking on it will add an underline style to all a
selectors on the website. I already wrote a simple function, but unfortunately it doesn't work.
There is a large number of a
selectors on the whole page, so I won't send out the code of the whole page.
JS file:
function underlineLinks() {
const links = document.querySelectorAll("a");
links.style.textDecoration = "underline";
}
HTML code:
<button onclick="underlineLinks()">Underline</button>
PHP code in functions.php file:
function underline_links() {
wp_enqueue_script( 'js-file', get_stylesheet_directory_uri() . '/js/underline.js');
}
add_action('wp_enqueue_scripts', 'underline_links');