If either this or * is clicked, then * do this, or * it is respectively

I was wondering if it is possible to do something like this using jQuery:

 $('#embedVid' || '#upldImg').click(function() {
  slide($('.vidEmbd') || $('#image_uploader_wrapper'));
 });

so if you click '#embedVid' and then pass' $ ('. vidEmbed') 'to the function' slide ', OR if you click' #upldImg 'and then pass' $ (' # image_uploader_wrapper ')' to ' slide?

It would be nice if I could put them in one click function ...

thank

+3
source share
1 answer

you can put the target class in the rel attribute of the object ...

$('#embedVid,#upldImg').click(function() {
  slide($($(this).attr('rel')));
 });

with:

<span id='embedVid' rel='.vidEmbd'>Some Text</span>$(
+6
source

Source: https://habr.com/ru/post/1779027/


All Articles