How to use OR Operation in jQuery Attribute Selectors?

jQueryWeb DevelopmentFront End Technology

Use comma to work with OR operation in jQuery Attribute Selector.


You can try to run the following code to learn how to use OR operation in jQuery attribute selector:

Live Demo

<!DOCTYPE html>
      <script src=""></script>
           $('[myattr=demo][myid="sub1"],[myattr=demo][myid="sub3"]').css("background-color", "yellow");
      <div myid="sub1" myattr="demo">Java</div>
      <div myid="sub2" myattr="demo">HTML</div>
      <div myid="sub3" myattr="demo">Ruby</div>
Published on 15-Dec-2017 13:23:25