javascript - Change background using a link's class -


first, sorry english, i'm french, so..

here problem. have menu, class="selected" active item. , have custom css class. works, so, it's ok this. but, i'd have different body's background pages. exemple, page1 must gray, page2 black, etc..

but, can't add class body (and then, change background css), because load pages same index.php file.

i thought solve problem bit of javascript? item has "selected" class, , apply custom body's background

thanks

there can lot of other different ways that. here 1 idea.

on page load using jquery's $(document).get ready, can selected menu. here rough idea whole.

<ul> <li bodybgcolor="red" class="selected"></li> <li bodybgcolor="green"></li> <li bodybgcolor="yell"></li> <ul>   $(document).ready(function() {   bodybgcolor =   $(.selected).attr("bodybgcolor");  $("body").css('background-color', 'blue');  } 

you can class=selected , bodybgcolor attribute set body color.

from server side : if dynamically generating menus , flagging selected class @ them , @ time defined body bg color in $bodybgcolor , can use same in body color or in styling.

<body background=""=<?php  echo $bodybgcolor; ?>> 

thanks


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -