Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging element ID with javascript
    primarykey
    data
    text
    <p>I am loading in the following navbar html from a required PHP file:</p> <pre><code> &lt;ul id="navlist"&gt; &lt;li id="active"&gt;&lt;a href="#" id="current"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="about.php"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="news.php"&gt;News&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="applying.php"&gt;Applying&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="current.php"&gt;Current &lt;br /&gt;Residents&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="alumni.php"&gt;Alumni&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Depending on the page that I am on (let's say I am on the alumni.php page) I want that list item to be given the ID "active"?</p> <p>Edit: Here is my header.php code:</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt; &lt;link rel="stylesheet" href="styles/main.css" type="text/css" media="screen" charset="utf-8"/&gt; &lt;link rel="stylesheet" href="styles/navbar.css" type="text/css" media="screen" charset="utf-8"/&gt; &lt;title&gt;some title&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="header"&gt; &lt;div id="left"&gt; &lt;img src="images/tree.png" alt="tree" width="87" height="98"&gt;&lt;/img&gt; &lt;/div&gt; &lt;div id="right"&gt; &lt; &lt;/div&gt; &lt;/div&gt; &lt;div id="navigation"&gt; &lt;ul id="navlist"&gt; &lt;li&gt;&lt;a href="index.php" id="current"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="about.php"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="news.php"&gt;News&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="applying.php"&gt;Applying&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="current.php"&gt;Current &lt;br /&gt;Residents&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="alumni.php"&gt;Alumni&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I assume that I need to do this through Javascript once the page loads? How would I do this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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