Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated About Me exercise #643

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions javascript/exercises/dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3 class="page-header">The Logo Hijack</h3>
img.width = 400;
img.src = 'http://www.logostage.com/logos/yahoo.GIF';
var button = document.getElementById('gbqfba');
button.innerHTML = 'Yahoooo!';
button.textContent = 'Yahoooo!';
</pre>

<h3 class="page-header">About Me</h3>
Expand All @@ -49,19 +49,22 @@ <h3 class="page-header">About Me</h3>
&lt;body&gt;
&lt;h1&gt;About Me&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Nickname: &lt;span id=&quot;nickname&quot;&gt;&lt;/span&gt;
&lt;li&gt;Favorites: &lt;span id=&quot;favorites&quot;&gt;&lt;/span&gt;
&lt;li&gt;Hometown: &lt;span id=&quot;hometown&quot;&gt;&lt;/span&gt;
&lt;/ul&gt;
&lt;dl&gt;
&lt;dt&gt;Nickname:&lt;/dt&gt;
&lt;dd id=&quot;nickname&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Favorites:&lt;/dt&gt;
&lt;dd id=&quot;favorites&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Hometown:&lt;/dt&gt;
&lt;dd id=&quot;hometown&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<li>Add a <code>script</code> tag to the bottom.
<li>Change the body style so it has a font-family of "Arial, sans-serif".
<li>Replace each of the spans (nickname, favorites, hometown) with your own information.
<li>Iterate through each li and change the class to "listitem". Add a <code>style</code>
<li>Iterate through each dt and change the class to "listitem". Add a <code>style</code>
tag that sets a rule for "listitem" to make the color red.
<li>Create a new <code>img</code> element and set its <code>src</code> attribute to
a picture of you. Append that element to the page.
Expand All @@ -83,18 +86,21 @@ <h3 class="page-header">About Me</h3>
&lt;body&gt;
&lt;h1&gt;About Me&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Nickname: &lt;span id=&quot;nickname&quot;&gt;&lt;/span&gt;
&lt;li&gt;Favorites: &lt;span id=&quot;favorites&quot;&gt;&lt;/span&gt;
&lt;li&gt;Hometown: &lt;span id=&quot;hometown&quot;&gt;&lt;/span&gt;
&lt;/ul&gt;
&lt;dl&gt;
&lt;dt&gt;Nickname:&lt;/dt&gt;
&lt;dd id=&quot;nickname&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Favorites:&lt;/dt&gt;
&lt;dd id=&quot;favorites&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Hometown:&lt;/dt&gt;
&lt;dd id=&quot;hometown&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;

&lt;script&gt;
document.body.style.fontFamily = 'Arial, sans-serif';
document.getElementById('nickname').innerHTML = 'Pamela Fox';
document.getElementById('favorites').innerHTML = '27';
document.getElementById('hometown').innerHTML = 'Pasadena, CA';
var items = document.getElementsByTagName('li');
document.getElementById('nickname').textContent = 'Pamela Fox';
document.getElementById('favorites').textContent = '27';
document.getElementById('hometown').textContent = 'Pasadena, CA';
var items = document.getElementsByTagName('dt');
for (var i = 0; i &lt; items.length; i++) {
items[i].className = 'listitem';
}
Expand Down
30 changes: 18 additions & 12 deletions jsweb/exercises/dom_manipulation_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ <h2 class="page-header">About Me</h2>
&lt;body&gt;
&lt;h1&gt;About Me&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Nickname: &lt;span id=&quot;nickname&quot;&gt;&lt;/span&gt;
&lt;li&gt;Favorites: &lt;span id=&quot;favorites&quot;&gt;&lt;/span&gt;
&lt;li&gt;Hometown: &lt;span id=&quot;hometown&quot;&gt;&lt;/span&gt;
&lt;/ul&gt;
&lt;dl&gt;
&lt;dt&gt;Nickname:&lt;/dt&gt;
&lt;dd id=&quot;nickname&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Favorites:&lt;/dt&gt;
&lt;dd id=&quot;favorites&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Hometown:&lt;/dt&gt;
&lt;dd id=&quot;hometown&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</li>
<li>Add a <code>script</code> tag to the bottom of the HTML body.</li>
<li>(In the JavaScript) Change the body tag's style so it has a font-family of "Arial, sans-serif".</li>
<li>(In the JavaScript) Replace each of the spans (nickname, favorites, hometown) with your own information.</li>
<li>Iterate through each <code>li</code> and change the class to "list-item".</li>
<li>Iterate through each <code>dt</code> and change the class to "list-item".</li>
<li>(In the HTML <code>head</code>) Add a <code>style</code> tag that sets a rule for <code>.list-item</code> to make the color red.</li>
<li>Create a new <code>img</code> element and set its <code>src</code> attribute to
a picture of you. Append that element to the page.</li>
Expand All @@ -159,18 +162,21 @@ <h2 class="page-header">About Me</h2>
&lt;body&gt;
&lt;h1&gt;About Me&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Nickname: &lt;span id=&quot;nickname&quot;&gt;&lt;/span&gt;
&lt;li&gt;Favorites: &lt;span id=&quot;favorites&quot;&gt;&lt;/span&gt;
&lt;li&gt;Hometown: &lt;span id=&quot;hometown&quot;&gt;&lt;/span&gt;
&lt;/ul&gt;
&lt;dl&gt;
&lt;dt&gt;Nickname:&lt;/dt&gt;
&lt;dd id=&quot;nickname&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Favorites:&lt;/dt&gt;
&lt;dd id=&quot;favorites&quot;&gt;&lt;/dd&gt;
&lt;dt&gt;Hometown:&lt;/dt&gt;
&lt;dd id=&quot;hometown&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;

&lt;script&gt;
document.body.style.fontFamily = 'Arial, sans-serif';
document.getElementById('nickname').textContent = 'Princess Bubblegum';
document.getElementById('favorites').textContent = 'science, music, my candy subjects';
document.getElementById('hometown').textContent = 'Candy Kingdom';
var items = document.getElementsByTagName('li');
var items = document.getElementsByTagName('dt');
for (var i = 0; i &lt; items.length; i++) {
items[i].className = 'list-item';
}
Expand Down