Click here to Skip to main content
15,892,059 members
Articles / Programming Languages / Javascript
Tip/Trick

Glowing menu bullets points with jquery

Rate me:
Please Sign up or sign in to vote.
4.00/5 (5 votes)
29 Apr 2011CPOL 15.2K   5   1
This is a short tutorial on how to make glowing bullet points that fade in when you move the mouse over and fade away afterwards
This simple technique places a bullet point image at the front of list menu items with jquery and then fades the bullet point in and out as the mouse moves over. It creates a subtle glowing effect.
An example can be seen here.

julia ostoepath

In order to make this work, you must include jquery
e.g.
<script type="text/javascript" src="somepath/jquery.js" /> 

The first block of code inserts a bullet point, and fades them all to 0% opacity

Right click and download this one if you have a brown website :)

C#
$(document).ready(function() {

     $("#block-menu-primary-links li").prepend("<img class='imbul' src='/sites/all/themes/osteopath/images/a3.png' />");

        $("#block-menu-primary-links li").mousedown(function() {
            $("#content").fadeOut("fast");
            $("#block-menu-primary-links li .imbul").stop().animate( {
                opacity : 0
            }, 200);
        });

    });


Note my menu is identified with #block-menu-primary-links.

Next, to fade the bullets in and out. Place this code after (outside) the document ready code.

#block-menu-primary-links

C#
$(function() {
    // OPACITY OF BUTTON SET TO 0%
    $("#block-menu-primary-links li .imbul").css("opacity", "0");

    // ON MOUSE OVER
    $("#block-menu-primary-links li").hover(function() {

        // SET OPACITY TO 100%
            $('.imbul',this).stop().animate( {
                opacity : 1.0
            }, 500);
        },

        // ON MOUSE OUT
            function() {

                // SET OPACITY BACK TO 50%
            $('.imbul',this).stop().animate( {
                    opacity : 0
                }, 3000);
            });
});

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
United Kingdom United Kingdom

Comments and Discussions

 
GeneralI like this effect a lot, you could tidy it slightly by inse... Pin
janebrown195724-Apr-11 22:49
janebrown195724-Apr-11 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.