Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Image swap jQuery help please
I have used jQuery javascript library for the main menu of a website. Please, click the items with arrows next to them. What I need is change the image to darr.gif whenever the sub-menu next to it is extended. Help me plz. thanks (the original image is rarr.gif)
0
This discussion has been closed.
Comments
http://visualjquery.com >> DOM >> Attributes
You can also add the arrow as a background and and change the class to change the arrow.
So, the script should somehow check whether the sub-menu is visible or not, which means that the line you mentioned would not work alone, i guess... thanks
<style> /* Hide the menu */ ul#menu ul { display: none; } /* if you don't need the animation: ul#menu li.showMenu ul { display: block; } */ /* Change the arrow */ ul#menu a.level1 { padding-right: 20px; background: transparent url(rarr.gif) center right no-repeat; } ul#menu li.showMenu a.level1 { background: transparent url(darr.gif) center right no-repeat; } </style> <script> $(document).ready(function(){ $(".level1 a").click(function(){ // get the parent of the clicked link //and add it the showMenu class if it doesn't have it // or remove the class, if it already have it $(this).parent().toggleClass("showMenu"); // Get the next sibling // and slide it up or down $(this).next().slideToggle('slow'); }); }); </script> ... <ul id="menu"> <li> <a class="level1" href="#">Cat 1</a> <ul> <li><a href="#">link 1</a></li> </ul> </li> </ul>
dInOboff