1

I have used:

document.getElementById("ElementName").style.display = 'block'; 

This is working. Now I would like to display the "ElementName" field on a button click. But this was not working:

document.getElementById("ElementName").style="display:block!important"
dfsq
  • 187,712
  • 24
  • 229
  • 250
lazyCat
  • 101
  • 1
  • 1
  • 13

3 Answers3

1

You can use this,

document.getElementById("challenges").style.cssText += "display : block !important"
Bharath
  • 519
  • 4
  • 7
0

Try this

document.getElementById("ElementName").style.display = "block !important"

//or 

document.getElementById("ElementName").style.display = "hide !important"
vmontanheiro
  • 989
  • 7
  • 12
0

What about this way... (if you really want to do) ?

Try to add given class :

var el = document.getElementById('ElementName');
el.className = el.className + ' block-important';

and add this in your CSS file :

.block-important {
   display: block!important;
}

But @torazaburo's answer says about using of important is correct

l2aelba
  • 20,261
  • 20
  • 97
  • 133