MyBB Community Forums

Full Version: Using a jQuery script?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to use this jQuery script and I know very little about JS or jQuery. I thought this would work but it doesn't... Could someone tell me what I'm doing wrong?


<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
$("a#login").click(function () {
    $("div#buttons").slideToggle();
    $("div#prompt").slideToggle();
});

$(".fakelink").click(function () {
    $("div#buttons").slideToggle();
    $("div#prompt").slideToggle();
});
</script>


Here's my website and you can see (in inspect element) that I've done everything correctly at least I think... forum.leftalt.com
(12-01-2014, 06:44 PM)ErraticFox Wrote: [ -> ]I've done everything correctly

No, the first line is incorrect - MyBB already loads jQuery, you shouldn't do it again. Add type attribute instead of src. Then you may have to wrap it with a code that would fire it after the DOM is loaded: http://learn.jquery.com/using-jquery-cor...ent-ready/ And lastly your IDs should be more unique than #login or #buttons especially that they're global, they may be duplicated somewhere in the theme.