• Hello,

    I want to use a randomising javascript on my site… to randomise some blocks of text…

    I have used this successfully in the past on my site – but it wasn’t a multisite then…

    Now I have a multisite installation and it is not working…

    Could you possibly help me sort this out/work out why?? Do you need to see the code??

    Thank you!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you provide a link to your site please, and maybe show the code that you’re using to implement your script?

    Thanks.

    Thread Starter cielle

    (@cielle)

    yes! thank you! my site is https://www.yeswearestars.gr

    the code ( i don’t have this on my site currently as it “broke” the page… )is this:

    function my_div_shuffler() {
    if (is_page(60)){
    	?>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    
    <script>
    (function($){
    $.fn.shuffle = function() {
    var allElems = this.get(),
    getRandom = function(max) {
    return Math.floor(Math.random() * max);
    },
    shuffled = $.map(allElems, function(){
    var random = getRandom(allElems.length),
    randEl = $(allElems[random]).clone(true)[0];
    allElems.splice(random, 1);
    return randEl;
    });
    this.each(function(i){
    $(this).replaceWith($(shuffled[i]));
    });
    return $(shuffled);
    };
    })(jQuery);
    </script>
    
    <script type="text/javascript">
    $(document).ready(function() {
           $('div.deeppink,div.white,div.hotpink,div.pink,div.orchid,div.plum,div.turquoise,div.violet').shuffle();
     });
     </script>
    
    <?php
    	}
    }
    add_action('wp_head', 'my_div_shuffler');
    Thread Starter cielle

    (@cielle)

    ok ok !! I am so sorry, this appears to now be working!!! I don’t even know what i did, it must have been something that i had not put in the correct place or something in my custom.php…
    so sorry, thank you so much for your time and help!
    Obviously, just my focus here with your help solved this!

    Great, glad to hear it.

    Thread Starter cielle

    (@cielle)

    thanks again…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘javascript not working …’ is closed to new replies.