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
  • 191,768
  • 25
  • 236
  • 258
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
  • 1,009
  • 9
  • 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
  • 21,591
  • 22
  • 102
  • 138