* Graham * Waplocus
you are only supposed to use an id once on a page they should be unique to that element
an active element is the one you just clicked on
so just give the divs a class instead of an id and declare .classname:active{...} in your css
note that a few browsers do not allow :active on anything other than a link or button

If you want to mark the current page in a header menu
this is the code that xtgem uses to mark the current page in xt_navigation containers
it adds a class of "active" to the current pages item in the menu
<script>
if ( document.getElementsByClassName ){
        window.__xt_mark_active_navigation = function (){
            var items = document.getElementsByClassName('xt_navigation');

            if ( items != undefined && items != null && items [0] != undefined )
            {
                items = items[0].childNodes;

                var loc = decodeURI ( document.location.pathname ).replace ( ' ', '+' ).replace ( /\/__xt.+/, '' );

                for (var i = 0; i < items.length; i++)
                {
                    if ( items [ i ].firstChild && items [ i ].firstChild.getAttribute && items [ i ].firstChild.getAttribute('href') == loc ) { items[i].className += ' active'; break; };
                }
            }
        };

        window.__xt_mark_active_navigation ();
    }
</script>

Copy code
it comes from this
http://xtgem.com/js/page_templates_simple.js
2016-09-08 12:54 (edited 2016-09-08 22:01 by Graham ) · (0)

Online: Guests: 1