javascript - i want to change the "margin-left" of a ul element when i click on an image -


<html> <ul> <li><a href="blocks.html">blocks</a></li> <li><a href="tools.html">tools</a></li> <li><a href="weapons.html">weapons</a></li> <li><a href="armour.html">armour</a></li> <li><a href="mobs.html">mobs</a></li> <li><a href="food.html">food</a></li> </ul>   <img onclick="somejavascriptcode" src="button.png">  </html> 

above simple naviagtion bar , image , incomplete onclick function.

<style> ul { list-style-type:none; margin:auto; padding:0; float: left; height:10%; width:10%; margin-left: -999px; } </style> 

above can see moved ul of page not effect rest of code.

how can make when button clicked on "margin-left: -999px;" changes "margin-left: 0px;" or other value.

this should work:

<ul id="myul"> ... </ul>  <img onclick="changemargin()" src="button.png">  <script> function changemargin () {     document.getelementbyid("myul").style.marginleft="0px"; } </script> 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -