Skip to content Skip to sidebar Skip to footer

How To Assign A Certain Style Id Div Tag

Good morning! I faced the problem create a javascript, that would restore the link with added style of a particular container div id. An example of my code:

Solution 1:

Attach a class to your divs and then use document.getElementsByClassName('class'). This will return an array of elements which you can adapt with a for loop.

Solution 2:

Use arguments

<script>
      functionchangeDiv(ids){
      document.getElementById(ids).style.width="230px";
      document.getElementById(ids).style.height="162px";
      document.getElementById(ids").style.top="0px";
    }
</script>

And use like

<ahref="#"onmouseover="changeDiv('image_1')"onmouseout="defaultDiv('do yourself')">Сантехника и электрика</a>

EDIT:(Answer to your comment)

<script>functionchangeDiv(ids){ document.getElementById(ids).style.borderRadius="5px"; } </script>

Post a Comment for "How To Assign A Certain Style Id Div Tag"