AlexR AlexR - 1 year ago 93
HTML Question

How to change the style of a div based on the current Domain

I have code that appears on two sites, lets call them and

I'd like to hide a div but only if the user is on sitetwo.

I have limited access to the html but i can insert code before and after the div i want hidden, including adding other divs and js. jquery is available also.

my thought is something like this:

code inserted before:

some js that changes the visibility of a div id 'hiddenontwo'
if domain = then set visibility of id=hiddenontwo to hidden
<div id=hiddenontwo> <!-- open a a wrapper div as i can't set an id on the actual div -->

Code inserted after:

</div> <!-- Closing the wrapper-->

is this possible?

as my js knowledge is zero, could someone be kind enough to show how it might be done?

Many thanks in advance

Answer Source

I think you could write something like that

  var divToHide = document.querySelector('#hiddenontwo');
  if( === "") { = 'hidden';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download