开发者

change the style of menu, if it is selected, without php

how can i change the style of menu, if it is selected, without php? i can do it by php

`<? if($_GET[id] == "this_menu") echo "style='color开发者_开发问答:red'"?>` 

but i want to do it without php. is it possible? thanks


if (document.location.search.match(/[?&]id=this_menu([&.*])?$/)) {
    document.getElementById('yourId').setAttribute('style', 'color: red');
}


Do you want to do that on client? if so, use JavaScript.


With JS

document.getElementById(gup("param")).setAttribute('style', 'color: red');

function gup( param ) {

var name = param.toLowerCase();
var regexS = "[\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS ); var tmpURL = window.location.href;
var results = egex.exec( tmpURL );
if( results == null ) { // Try to find an alternative value
if (typeof alternatives == "object") {
if(typeof alternatives[name] !="undefined") { return alternatives[name];
}
} return "";
} else {
return results[1];
} };


it can be done easily done by javascript:

use something like this

document.getElementById('myMenu').style.color='#f0f0f0';

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜