<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>前端思考：专注前端开发，关注用户体验 &#187; 提示</title>
	<atom:link href="http://www.artcss.com/archives/tag/%e6%8f%90%e7%a4%ba/feed" rel="self" type="application/rss+xml" />
	<link>http://www.artcss.com</link>
	<description>一个像素的距离...</description>
	<lastBuildDate>Sat, 12 Feb 2011 03:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>javascript商品提示效果</title>
		<link>http://www.artcss.com/archives/327.html</link>
		<comments>http://www.artcss.com/archives/327.html#comments</comments>
		<pubDate>Sat, 10 Oct 2009 07:50:21 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[提示]]></category>

		<guid isPermaLink="false">http://www.artskin.cn/blog/?p=327</guid>
		<description><![CDATA[今天写一个商品展示信息提示的js小例子，就是当鼠标放到商品图片上的时候出现一个半透明层，层上写商品的相关信息。 用到的javascript代码如下： Download script.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 var oLight = document.getElementById&#40;&#34;light&#34;&#41;; var oList = oLight.getElementsByTagName&#40;&#34;li&#34;&#41;; for &#40;var i=0,iLen = oList.length; i&#60;iLen; i++&#41;&#123; oList&#91;i&#93;.onmouseover = function&#40;&#41;&#123; var oSpan = this.getElementsByTagName&#40;&#34;span&#34;&#41;&#91;0&#93;; var oImg = this.getElementsByTagName&#40;&#34;img&#34;&#41;&#91;0&#93;; oSpan.style.display=&#34;block&#34;; oSpan.innerHTML=oImg.alt; &#125; oList&#91;i&#93;.onmouseout = function&#40;&#41;&#123; var oSpan = this.getElementsByTagName&#40;&#34;span&#34;&#41;&#91;0&#93;; var [...]]]></description>
			<content:encoded><![CDATA[<p>今天写一个商品展示信息提示的js小例子，就是当鼠标放到商品图片上的时候出现一个半透明层，层上写商品的相关信息。</p>
<h5>用到的javascript代码如下：</h5>
<p><span id="more-327"></span></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=327&amp;download=script.js">script.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3272"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p327code2"><pre class="javascript" style="font-family:Verdana;"><span style="color: #003366; font-weight: bold;">var</span> oLight <span style="color: #339933;">=</span> document.<span style="color: #990000;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;light&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> oList <span style="color: #339933;">=</span> oLight.<span style="color: #990000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #ff0000;">0</span><span style="color: #339933;">,</span>iLen <span style="color: #339933;">=</span> oList.<span style="color: #990000;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>iLen<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	oList<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #990000;">onmouseover</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> oSpan <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #990000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> oImg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #990000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		oSpan.<span style="color: #990000;">style</span>.<span style="color: #990000;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">;</span>
		oSpan.<span style="color: #990000;">innerHTML</span><span style="color: #339933;">=</span>oImg.<span style="color: #990000;">alt</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	oList<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #990000;">onmouseout</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> oSpan <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #990000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> oImg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #990000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		oSpan.<span style="color: #990000;">style</span>.<span style="color: #990000;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_XpJ1It">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;author&quot; content=&quot;artskin@163.com,guliqiang&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;前端思考&quot; /&gt;
&lt;meta content=&quot;all&quot; name=&quot;robots&quot; /&gt;
&lt;title&gt;js商品提示效果 || 前端思考&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
h2{padding-left:50px;}
li{width:160px;height:158px;float:left;margin-left:8px;list-style:none;position:relative;border:1px solid #ccc;padding:3px;}
li img{width:160px;height:158px;}
li span{display:none;width:166px;height:30px;position:absolute;left:0;bottom:0;background:#ccc;
filter:alpha(opacity=40);opacity:0.4;zoom:1;text-align:center;font-size:12px;line-height:30px;color:#000;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;秀一秀我的N82&lt;/h2&gt;
&lt;ul id=&quot;light&quot;&gt;
	&lt;li&gt;&lt;img src=&quot;wp-content/uploads/test/img/my_nokia1.jpg&quot; alt=&quot;时尚耐用&quot; /&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;wp-content/uploads/test/img/my_nokia2.jpg&quot; alt=&quot;包装盒&quot; /&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;wp-content/uploads/test/img/my_nokia3.jpg&quot; alt=&quot;手感不错&quot; /&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;wp-content/uploads/test/img/my_nokia4.jpg&quot; alt=&quot;我的爱机&quot; /&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	var oLight = document.getElementById(&quot;light&quot;);
	var oList = oLight.getElementsByTagName(&quot;li&quot;);
	for (var i=0,iLen = oList.length; i&lt;iLen; i++){
		oList[i].onmouseover = function(){
			var oSpan = this.getElementsByTagName(&quot;span&quot;)[0];
			var oImg = this.getElementsByTagName(&quot;img&quot;)[0];
			oSpan.style.display=&quot;block&quot;;
			oSpan.innerHTML=oImg.alt;
		}
		oList[i].onmouseout = function(){
			var oSpan = this.getElementsByTagName(&quot;span&quot;)[0];
			var oImg = this.getElementsByTagName(&quot;img&quot;)[0];
			oSpan.style.display=&quot;none&quot;;
		}
	}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_XpJ1It');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_XpJ1It');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/327.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

