<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: javascript code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 19 Aug 2008 14:48:24 GMT</pubDate>
    <description>DZone Snippets: javascript code</description>
    <item>
      <title>Sanitize runaway Z indexes!</title>
      <link>http://snippets.dzone.com/posts/show/821</link>
      <description>This is a function I wrote to sanitize zIndexes of a list of elements that you may continually are bringing to the top of a page.  This function goes through HTML Elements and makes all the numbers as low as can be without affecting ordering. &lt;br /&gt;&lt;br /&gt;Feel free to make suggestions or to use this code how you'd like. &lt;br /&gt;&lt;br /&gt;One condition, please just tell me if you're using it, and if you have ideas for improvement, let me know&lt;br /&gt;kenny[@t  ]]]standsolid.com&lt;br /&gt;&lt;br /&gt;&lt;code&gt;function sanitizeZ(elements){&lt;br /&gt;&lt;br /&gt;	function sortByZIndex(a, b){&lt;br /&gt;		return a[1] - b[1];&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	var tempZArray = new Array();&lt;br /&gt;	for(i in elements)&lt;br /&gt;		tempZArray.push([i, elements[i].style.zIndex]);&lt;br /&gt;&lt;br /&gt;	tempZArray.sort(sortByZIndex);&lt;br /&gt;&lt;br /&gt;	for(i in tempZArray)&lt;br /&gt;		elements[ tempZArray[i][0] ].style ['zIndex'] = i;&lt;br /&gt;&lt;br /&gt;}&lt;/code&gt;</description>
      <pubDate>Wed, 19 Oct 2005 11:57:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/821</guid>
      <author>standsolid (Kenny)</author>
    </item>
  </channel>
</rss>
