I would like to know how to call two different divs using a single Onclick() function in JavaScript.
I have two divs and a button (Right now I have 2 buttons each for a single div). whenever these buttons are pressed then the 2 divs need to execute. I just don't know how to call two divs at a time.
Here is the sample code.
<div id="scroll" style="position:relative; width:100px; height:40px;"></div>
<input type="button" name="" value="Scroll" onclick="zxcTextScroller.Scroll('scroll');" />
<div id="scroll2" style="position:relative; width:100px; height:40px;"></div>
<input type="button" name="" value="Scroll" onclick="zxcTextScroller.Scroll('scroll2');" />
How to control these two divs by using a single Onclick Event? Am using two Onclick Events but I need to have only single onclick which calls both the div's.
Thanks
zxcTextScroller.Scroll('scroll');andzxcTextScroller.Scroll('scroll2');together when you click on something? Why not put these two sentences into one onclick function?<div id="scroll" class="js-clickable-scroll" style="position:relative; width:100px; height:40px;"></div>and<div id="scroll2" class="js-clickable-scroll" style="position:relative; width:100px; height:40px;"></div>and then trigger the scroll for elements withjs-clickable-scrollclass.js-clickable-scrolland it will work for the 3rd too as you trigger for all elements with that class.