Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to tell IE about the tag first. Add this line somewhere before calling <code>addDateFormatInfo()</code>:</p> <pre><code>document.createElement("showDateFormat"); </code></pre> <p>IE will now initialize the element correctly - you can treat it just like any other element. Firefox does this automatically.</p> <p>Here's the source blog post:</p> <p><a href="http://ajaxian.com/archives/getting-html-5-styles-in-ie-7" rel="nofollow noreferrer">http://ajaxian.com/archives/getting-html-5-styles-in-ie-7</a></p> <p>Support for <code>createElement()</code> starts in IE7 - though I works fine in FF3.0.15</p> <h3>Full Example</h3> <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=utf-8" /&gt; &lt;title&gt;Home | My Website&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; document.createElement("showDateFormat"); function addDateFormatInfo(){ var dateFormatHolder = document.getElementsByTagName("showDateFormat"); if ( dateFormatHolder ){ for ( i = 0 ; i &lt; dateFormatHolder.length; i++ ){ dateFormatHolder[i].innerHTML = '&lt;div class="infoSmall" &gt;&lt;span&gt;(mm/dd/yyyy)&lt;/span&gt;&lt;/div&gt;'; } } } &lt;/script&gt; &lt;div&gt; Date From:&lt;showDateFormat/&gt; &lt;/div&gt; &lt;div&gt; Date From:&lt;showDateFormat/&gt; &lt;/div&gt; &lt;div&gt; Date From:&lt;showDateFormat/&gt; &lt;/div&gt; &lt;div&gt; Date From:&lt;showDateFormat/&gt; &lt;/div&gt; &lt;p&gt;&lt;input type="button" value="click me" onclick="addDateFormatInfo()" /&gt; &lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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