We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    Not really a modx question*

    	<script type="text/javascript">
    		$(document).ready(function() {
    
    		$("a[rel=gallery01]").fancybox({
    		  'transitionIn'  : 'none',
    		  'transitionOut' : 'none',
    		  'titlePosition' : 'over',
    		  'titleFormat'	  : function(title, currentArray, currentIndex, currentOpts) {
    		return '<span id="fancybox-title-over">Afbeelding ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '   ' + title : '') + '</span>';
    				}
    			});
    		});
    	</script>


    How can I reduce this script?

    I have to add rel=gallery02 , rel=gallery03 , rel=gallery04 and I don't want to add the whole script.
      Evolution user, I like the back-end speed and simplicity smiley
      • 9995
      • 1,613 Posts
      I think I solved it

      $("a[rel=gallery01] , a[rel=gallery02] , a[rel=gallery03] , a[rel=gallery04] ").fancybox({
        Evolution user, I like the back-end speed and simplicity smiley
        • 6629
        • 60 Posts
        You could use jQuerys attributeStartsWith selector:

        $("a[rel^='gallery']").fancybox()


        Or add a class to every gallery link an use a normal class-selector:

         $(".galleryLink").fancybox()