-1

what is the best way to replace all the values with a given attribute in HTML DOM and CSS.

Below is the example of replacing all block values with none, Should replace all the occurrence of the given input.

ex: <a href="#" onclick="document.getElementById('infoDiv0').style.display='block';"> p.ex1 {display: block;} TO <a href="#" onclick="document.getElementById('infoDiv0').style.display='none';"> p.ex1 {display: none;}

is there any chrome extension for it?

Arbazz Hussain
  • 1,622
  • 2
  • 15
  • 41
  • Possible [X/Y problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem): it looks like you want to change the action that these onclick handlers do upon some other event. Please explain why you want to change the "block" to "none". There might be a better solution than finding all elements with a certain signature and replacing text. – try-catch-finally Dec 17 '18 at 22:58

1 Answers1

1

You should look into bootstrap https://getbootstrap.com/.

The better option would be to use classes and give all the ones you are hiding the class class='hide'.

Then when it it time to display/hide them, you simply $ ('classname_or_id').removeClass ('hide') or $ ('classname_or_id').addClass ('hide'). this is jquery but you can also do it with just javascript;

Id is to target just one element. Using class names you can target multiple at once

See: JavaScript and getElementById for multiple elements with the same ID

John Watts
  • 83
  • 1
  • 4
CAllen
  • 856
  • 5
  • 14