/ Published in: JavaScript

Connects multiple items on a page on click by pulling arrays of ids from the json
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Json: "connections":[ ["button0","financials_li_0"], ["button1"], ["button2","order_fulfillment_li_0"], ["button3"], ["button4"], ["button5","order_fulfillment_li_1","material_management_li_0"] ] javascript: //add and removes the focus class on click, define groups in the Json 'connections' function connect(array) { $.each(array, function(index,value) { $("#"+value).click(function(){ $("div,li").removeClass("focusClass"); $.each(array, function(index,value ) { $("#"+value).addClass("focusClass"); }); }); }); }
Comments
