0

I add css property to a button with: $('#salvaImpegno').css("cursor", "not-allowed"); and it works.

But I can't remove it. I tried with: $('#salvaImpegno').removeProp("cursor");, but it doesn't work.

Why?

2

3 Answers 3

3

Because css is not a property.

Use

$('#salvaImpegno').css('cursor', '');

or

$('#salvaImpegno').css('cursor', 'default');
Sign up to request clarification or add additional context in comments.

Comments

0

Because css is not a property.

You have to remove the property style.

like this:

$('#salvaImpegno').removeProp("style");

or more correctly

 $('#salvaImpegno').removeAttr("style");

because style is an attribute, more than a property of an element.

But it will remove all the styles you added through .css() method. If you want to only reset cursor property refer other answers.

Comments

0

instead you can try using .addClass(), so maybe you can do something like

$('#salvaImpegno').css("cursor", "not-allowed");

and then when you want to remove the "cursor" you can add a class that overrides the other like this.

/----CSS---/

.cursorOverride{
  cursor: pointer !important;
}

/---js---jQuery----/

$('#salvaImpegno').addClass("cursorOverride");

If you want to be able to reomve the class you can do that with .removeClass(). I hope this helps!

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.