Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <div id="prefix_0_sufix"></div>
  2. <div id="prefix_1_sufix"></div>
  3. <div id="prefix_2_sufix"></div>
  4. ... and so on ...
  5.  
  6. $('div[id^="prefix_"][id$="_sufix"]');
  7.  
  8. <div class="foo" data-bar="0"></div>
  9. <div class="foo" data-bar="1"></div>
  10. <div class="foo" data-bar="2"></div>
  11.  
  12. var $secondDiv = $('.foo').filter(function() {
  13. return $(this).data('bar') == 1;
  14. });
  15.  
  16. var $secondDiv = $('.foo:eq(1)');
  17.  
  18. $('div[id^="prefix"]').filter(
  19. function(){
  20. return this.id.match('suffix');
  21. }).css('background-color','#0f0');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement