Jquery + CSS to highlight the current page of Navigation

Source: Internet
Author: User
CSS: CSS
# PL # pl_menu {}
. Plmenu_head {Height: 20px; padding: 10px 0 0 20px; width: 180px; font-weight: bold; Background: transparent URL (.. /image/web/LP/menu_head.gif) No-repeat scroll 0 ;}
. Plmenu_select {Background: transparent URL (.. /image/web/LP/menu_select.gif) No-repeat scroll 0; Height: 26px; line-Height: 26px; text-indent: 30px ;}
. Plmenu_normal {Background: transparent URL (.. /image/web/LP/menu_normal.gif) No-repeat scroll 0; Height: 26px; line-Height: 26px; text-indent: 30px ;}
. Plmenu_bottom {Background: transparent URL (../image/web/LP/menu_bottom.gif) No-repeat scroll 0; margin-top:-2px ;}

HTML: HTML

<Div class = "plmenu_head"> about us </div>
<Div id = "aboutus_menu" class = "plmenu_normal"> <a class = "head_link" href = "aboutus.html"> about us </a> </div>
<Div id = "companynews_menu" class = "plmenu_normal"> <a class = "head_link" href = "companynews.html"> company news </a> </div>
<Div id = "hr_menu" class = "plmenu_normal"> <a class = "head_link" href = "hr.html"> job opportunities </a> </div>
<Div id = "clientlist_menu" class = "plmenu_normal"> <a class = "head_link" href = "clientlist.html"> our customers </a> </div>
<Div id = "link_menu" class = "plmenu_normal"> <a class = "head_link" href = "link.html"> Links </a> </div>
<Div id = "contact_menu" class = "plmenu_normal"> <a class = "head_link" href = "contact.html"> Contact Us </a> </div>
<Div id = "" class = "plmenu_bottom"> </div>

JS: JS

<SCRIPT type = "text/JavaScript">
Window. onload = function ()
{
Setmenubackground ();
}

Function setmenubackground ()
{
VaR url = Document. url; // obtain the URL of the current page

If (/contact/. Test (URL. tolowercase () // regular query whether the current page exists in the URL address
{
$ ("# Contact_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
} Else if (/aboutus/. Test (URL. tolowercase ()))
{
$ ("# Aboutus_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
} Else if (/link/. Test (URL. tolowercase ()))
{
$ ("# Link_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
} Else if (/clientlist/. Test (URL. tolowercase ()))
{
$ ("# Clientlist_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
} Else if (/HR/. Test (URL. tolowercase ()))
{
$ ("# Hr_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
} Else if (/companynews/. Test (URL. tolowercase ()))
{
$ ("# Companynews_menu"). removeclass ("plmenu_normal"). addclass ("plmenu_select ");
}
}
</SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.