Hello.
I need the logo of the site to change according to the page that the user visits.
I have a site made in PHP in which the top is include
. So I thought about changing the logo via Javascript.
I set ID="logo"
to img
and ID
to body
of pages that will have a different logo. So I hoped that through If
/ Else
, checking whether or not there was ID
in body
, src
of the image changed. But it's not rolling. I'm not a programmer and I came here searching on Google. rs
Here are my codes:
HTML
<img id="logo" src="<?=$img_dir?>/logo_ultraclimber-resgate.png" alt="Ultra Climber Treinamentos e Serviços" />
JS
<script type="text/javascript">
if ('body[id="treina"]') {
document.getElementById("logo").src='_include/images/logo_ultraclimber-treinamentos.png';
} if else ('body[id="serv"]') {
document.getElementById("logo").src='_include/images/logo_ultraclimber-servicos.png';
} else {
document.getElementById("logo").src='_include/images/logo_ultraclimber-resgate.png';
}
Thanks for the help! =]