MyBB Community Forums

Full Version: Help with this jQuery function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, first of all, if you don't understand me, it's okey because my english sucks xD.

I have this: http://jsfiddle.net/pcFa8/

What is that? It's a simple code to hide/fadein news/quotes/etc. randomly with jQuery.

BUT, I really suck on jQuery... so, if anybody can help me to solve this, well, everybody can use it.

The problem is... in jsfiddle the code work, but in mybb don't... and like I said before, I don't know java/jQuery.

If anyone can help me, welcome.

P.D.: This is not my code, I extract this from internet, and I'm trying to put this to work.

Greetings.
You need to:
1) Load jQuery in noConflict mode in headerinclude template. Like this:
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
    document.write(unescape("%3Cscript src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">jQuery.noConflict();</script>
Make sure it's loaded only 1 time.
2) Put JS code from fiddle inside <script type="text/javascript"></script> tag to any template after jQuery is loaded (so in headerinclude below it, in other templates below {$headerinclude})
3. Replace $ in front of selectors in the inserted JS code to jQuery. For instance:
$("#tips li").length;
to:
jQuery("#tips li").length;
4) Make sure your HTML is correct and works with this functon (so basically same or similar as in fiddle).
I'm loving you, thanks a lot man!