<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Javascript</id>
	<title>Javascript - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Javascript"/>
	<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Javascript&amp;action=history"/>
	<updated>2026-11-15T12:32:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Javascript&amp;diff=1561&amp;oldid=prev</id>
		<title>Leo: Created page with &quot;This page will contain some common &#039;&#039;&#039;vanilla&#039;&#039;&#039; javascript information. Not Javascript frameworks such as jQuery or AngularJS.  == Operations == === Retrieving DOM elements =...&quot;</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Javascript&amp;diff=1561&amp;oldid=prev"/>
		<updated>2016-01-12T18:45:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This page will contain some common &amp;#039;&amp;#039;&amp;#039;vanilla&amp;#039;&amp;#039;&amp;#039; javascript information. Not Javascript frameworks such as jQuery or AngularJS.  == Operations == === Retrieving DOM elements =...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This page will contain some common &amp;#039;&amp;#039;&amp;#039;vanilla&amp;#039;&amp;#039;&amp;#039; javascript information. Not Javascript frameworks such as jQuery or AngularJS.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
=== Retrieving DOM elements ===&lt;br /&gt;
Consider the following HTML:&lt;br /&gt;
{{highlight|lang=html4strict|code=&lt;br /&gt;
&amp;lt;div id=&amp;quot;link-container&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a id=&amp;quot;link&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;Click Me&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== By ID ====&lt;br /&gt;
{{highlight|lang=javascript|code=&lt;br /&gt;
var container = document.getElementById(&amp;#039;link-container&amp;#039;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==== By Tag Name ====&lt;br /&gt;
{{highlight|lang=javascript|code=&lt;br /&gt;
var containers = document.getElementsByTagName(&amp;#039;div&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
// Number of elements found: containers.length &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Modifying Attributes ===&lt;br /&gt;
With an element selected, attributes can be modified using {{code|getAttribute(name)}} and {{code|setAttribute(name, value)}}.&lt;br /&gt;
&lt;br /&gt;
{{highlight|lang=javascript|code=&lt;br /&gt;
var link = document.getElementById(&amp;#039;link&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
// url set to href attribute, currently &amp;#039;#&amp;#039;&lt;br /&gt;
var url = link.getAttribute(&amp;quot;href&amp;quot;);&lt;br /&gt;
link.setAttribute(&amp;quot;href&amp;quot;, &amp;quot;http://leo.leung.xyz&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Javascript]]&lt;/div&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
</feed>