Note that there are some explanatory texts on larger screens.

plurals
  1. POApply class on <a href> using javascript
    text
    copied!<p>I am using php. Create a file leftcolumn.php which includes following codes..</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;script language="javascript"&gt; function setClass( tabName ){ document.getElementById(tabName).style.background = '#f0f7fa'; document.getElementById(tabName).style.color = '#c66653'; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="sidebar"&gt; &lt;img src="images/logo.png" /&gt; &lt;ul class="sideNav"&gt; &lt;!-- Use class="active" for selected tab --&gt; &lt;li&gt;&lt;a id="dashboard" href="cms.php" onclick="setClass('dashboard');"&gt;Dashboard&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="mainMenu" href="menus.php"&gt;Main Menus&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="retailers" href="#"&gt;Retailers&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="productimages" href="productimages.php"&gt;Product Images&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="pressreleases" href="pressreleases.php"&gt;Press Releases&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="news" href="news.php"&gt;In the News&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;!-- // .sideNav --&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now, I just want to apply background = '#f0f7fa' &amp; color = '#c66653' (on active tab) when user click on a tab, for this I created a function but it does not apply change.....!</p> <p>Kindly help to solve it....</p> <p>Thanks.....</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload