Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just finished my aim so I post my code here, I think it is the simplest way,and clear</p> <pre><code>$(document).ready(function() { var btns = { 'bg_o' : ['images/services/btn1.png','images/services/btn2.png','images/services/btn3.png','images/services/btn4.png'], 'bg_h' : ['images/services/btn1_hover.png','images/services/btn2_hover.png','images/services/btn3_hover.png','images/services/btn4_hover.png'], '$all_btn' : $('.all_btn'), '$folders':[$('#folder1'),$('#folder2'),$('#folder3'),$('#folder4')], 'folders_status':new Array('inactive','inactive','inactive','inactive') ,jquery_func : function(){ btns.$all_btn.each(function(){ $(this).click(function(){ for(i=0;i&lt;4;i++){ var imageurl_o = new Array(); imageurl_o[i] = {'background-image':'url('+btns.bg_o[i]+')'}; btns.$folders[i].css(imageurl_o[i]); btns.folders_status[i]='inactive'; } for(i=0;i&lt;4;i++){ var myparent = btns.$folders[i].parent(); if($(this).attr('class') == myparent.attr('class')){ var imageurl_h = {'background-image':'url('+btns.bg_h[i]+')'}; btns.$folders[i].css(imageurl_h); btns.folders_status[i]='active'; } } }); $(this).mouseover(function(){ for(i=0;i&lt;4;i++){ var imageurl_o = new Array(); imageurl_o[i] = {'background-image':'url('+btns.bg_o[i]+')'}; if(btns.folders_status[i]=='inactive') btns.$folders[i].css(imageurl_o[i]); } for(i=0;i&lt;4;i++){ var myparent = btns.$folders[i].parent(); if($(this).attr('class') == myparent.attr('class')){ var imageurl_h = {'background-image':'url('+btns.bg_h[i]+')'}; btns.$folders[i].css(imageurl_h); } } }); }); } } btns.jquery_func(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload