0

I have a url in my HTML as seen below. I have made the url inactive

<a style="pointer-events: none; color: rgb(44, 89, 159);" href="https://www.google.com/" id="successfactors">Link</a>

I am trying to reactivate the link via Javascript. I tried the code below, but when I did the page didn't load correctly. Does anyone know what I'm doing wrong or a better way to make a link inactive/active?

document.getElementById('successfactors').style.pointer-events = 'auto';
1
  • - is not valid in dot notation, use bracket notation: .style['pointer-events'] = '...' Commented Nov 4, 2014 at 16:05

2 Answers 2

5

I would recommend you use CSS and javascript in a manner which clearly distinguishes the two.

Define your CSS styles:

.inactive
{
   pointer-events: none;
   color: rgb(44, 89, 159);
}

.active
{
   pointer-events: auto;
}

Toggle the CSS class of the elements with javascript:

document.getElementById("successfactors").className = "inactive";

It's neater and tidier, and I promise you widely-used inline styles eventually cause headaches.

Sign up to request clarification or add additional context in comments.

Comments

0

Use:

document.getElementById('successfactors').style.pointerEvents = 'auto';

Styles use camel case, as identifiers can't contain hyphens.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.