I have this code:
$("#leftbutton").click(function(e){ /// do xyz }); $("#rightbutton").click(function(e){ /// do xyz (same thing) });
How to combine them so that when you click #leftbutton or #rightbutton xyz?
Something like that:
$("#leftbutton OR #rightbutton").click(function(e){ /// do xyz });
Use a comma, also known in jQuery docs, as a multiple selector :
$("#leftbutton, #rightbutton").click(function(e){ /// do xyz });
Like CSS selectors, you can use a comma
Just do:
$("#leftbutton, #rightbutton").click(function(e){ ... });
Source: https://habr.com/ru/post/1775710/More articles:drawing a line between two points - javaIs it bad practice to create software that does not work on a historical date? - language-agnosticHow to determine if a matrix is “positive definite” through SQL? - sql-serverArray Iteration - objective-chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1775709/how-do-i-associate-a-file-extension-with-an-application-using-a-desktop-file-under-linux&usg=ALkJrhi-CzdAnY3mAp7_QjKRXoMEzla0PQtypehinting: метод должен принимать любой $arg, являющийся объектом - oopThe algorithm for finding the minimum spanning tree when the cost is specified by multiplying the weights of the edges - optimizationTransparent accent color - windows-phone-7iPhone - Basic Data Bool Values? - objective-cA compiled EF request occasionally raises a SqlException - c #All Articles