首页 新闻 会员 周边

【为什么JQ 事件加载失效 】

0
悬赏园豆:20 [已解决问题] 解决于 2012-06-29 21:43

$(function(){

alert('进入了!'); //可以执行

//我是通过class获取 document  Element 

$(".class").size() 结果大于0;

$(".class").html() 结果不为NULL;

$(".class").mouseover(function(){ alert('鼠标划过了!');}); //不可以执行

});

 

为什么没有加载mouseover(里的方法呢);

<script src="../js/jquery-1.4.1.min.js" type="text/javascript"></script>

FF 13.0  FFbug 1.92  VS2005

在一些同事的IE8.0可以运行图片的事件 在他FF上就不行了 包括其实的浏览器。

在我的本机上 都失效。

我自己在2010VS 上运行可以 。

【个人猜测: 是不是JQ和其实JS文件有冲突了.  】

Mundo Novo的主页 Mundo Novo | 初学一级 | 园豆:69
提问于:2012-06-27 13:50
< >
分享
最佳答案
0

你的.document是什么,代码放在什么地方执行的呢?

这个例子中可以正常运行的啊:

http://jscode.chinacxy.com/cf_4880d09008a6d670b752566ba9402abd.aspx

收获园豆:15
artwl | 专家六级 |园豆:16736 | 2012-06-27 14:00

是个class 【形容的。】 在146行   我在您给的网站写了个正确的 但是带入我的页面 还是失效了。

 

  1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Special_Index" %>
  2 
  3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4 <html xmlns="http://www.w3.org/1999/xhtml">
  5 <head runat="server">
  6     <title>旅游专题-旅游招标网</title>
  7     <meta name="keywords" content="旅游交易平台,旅游,旅游网" runat="server" id="keywords" />
  8     <meta name="description" content="" runat="server" id="description" />
  9     <link href="../Special/css/guzhen.css" rel="stylesheet" type="text/css" runat="server"
 10         id="zt_css" />
 11     <link href="../Special/css/base.css" rel="stylesheet" type="text/css" />
 12     <link href="../Special/css/cn.css" rel="stylesheet" type="text/css" />
 13 
 14     <script src="../js/jquery-1.4.1.min.js" type="text/javascript"> </script>
 15 
 16 </head>
 17 <body>
 18     <div class="all1 cl">
 19         <div class="top cl">
 20             <div class="topl fl">
 21                 <a href="http://www.nuoya114.com">
 22                     <img src="img/sy_04.jpg" /></a>
 23             </div>
 24             <div class="topr fl">
 25                 <div class="toprs cl">
 26                     <asp:Panel ID="userNan" runat="server">
 27                         <ul>
 28                             <li>
 29                                 <img src="img/sy_07.jpg" /></li><li><a href="http://www.nuoya114.com/MemberCenter/UI/Login.html">
 30                                     登录</a></li><li>|</li><li><a href="http://www.nuoya114.com/MemberCenter/UI/Register.html">
 31                                         注册账号</a></li><li>|</li><li><a href="http://www.nuoya114.com/MemberCenter/UI/getpass.aspx">
 32                                             找回密码</a></li></ul>
 33                     </asp:Panel>
 34                     <asp:Panel ID="userInfo" runat="server">
 35                         <asp:Literal runat="server" ID="userName"></asp:Literal>
 36                         | <a href="http://www.nuoya114.com/MemberCenter/UI/index.aspx">会员管理中心</a> | <a href="http://www.nuoya114.com/MemberCenter/ui/Bid_Manage.aspx">
 37                             管理招标信息</a>
 38                     </asp:Panel>
 39                 </div>
 40                 <div class="toprx cl">
 41                     <ul>
 42                         <li>
 43                             <img src="img/sy_10.jpg" /></li><li><a href="zt.html#haibin">浪漫海滨 </a></li>
 44                         <li>|</li><li><a href="zt.html#shanshui">山水文化 </a></li>
 45                         <li>|</li><li><a href="zt.html#guzhen">古镇休闲 </a></li>
 46                         <li>|</li><li><a href="zt.html#caoyuan">草原旅游 </a></li>
 47                         <li>|</li><li><a href="zt.html#yiguo">异国风情</a></li></ul>
 48                 </div>
 49             </div>
 50         </div>
 51     </div>
 52     <div class="content cl">
 53         <div class="flashs cl">
 54         </div>
 55         <div class="fla">
 56             <div class="fanhui">
 57                 <a title="返回首页" href="zt.html">
 58                     <img src="img/fanhuishouye.png" runat="server" id="imgBackHome" /></a></div>
 59         </div>
 60         <input id="imagepath" type="hidden" value='<%= imagepath %>' />
 61         <div class="diyic">
 62             <div class="cons cl">
 63                 <div class="diyiconl fl">
 64 
 65                     <script type="text/javascript">
 66                         var focus_width = 500;
 67                         var focus_height = 322;
 68                         var text_height = 0;
 69                         var swf_height = focus_height + text_height;
 70                         var pics = "img/fla.jpg|img/fla.jpg";
 71                          var imagePath =document.getElementById("imagepath").value;
 72                                 if(imagePath!=null && imagePath!='')
 73                                 {
 74                                      pics= imagePath;
 75                                 }  
 76                         var links = "index.htm|index.htm";
 77                         var texts = 'nihao|nihao'
 78                         document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + focus_width + '" height="' + swf_height + '"><param name="allowScriptAccess"  value="sameDomain" /><param name="movie" value="swf/pixviewer.swf" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="transparent" /><param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + (focus_width + 2) + '&borderheight=' + (focus_height + 2) + '&textheight=' + text_height + '" />');
 79                         document.write('<embed src="swf/pixviewer.swf" wmode="transparent" flashvars="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '" menu="false"   quality="high" width="' + focus_width + '" height="' + swf_height + '" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
 80                         document.write('</object>');
 81                     </script>
 82 
 83                 </div>
 84                 <div class="diyiconr fl">
 85                     <div class="diyiconrs cl">
 86                         <strong>
 87                             <asp:Literal runat="server" ID="ltrSpecialName"></asp:Literal></strong>
 88                     </div>
 89                     <div class="diyiconrx cl">
 90                         <p>
 91                             <asp:Literal runat="server" ID="ltrSpecialInfo"></asp:Literal>
 92                         </p>
 93                     </div>
 94                 </div>
 95                 <%--OK--%>
 96             </div>
 97             <div class="diyi cl">
 98             </div>
 99             <asp:Repeater runat="server" ID="rptJingdiantuijian">
100                 <ItemTemplate>
101                     <div class="zhuantia cl show">
102                         <div class="zhuantitop cl">
103                             <div class="zhuantitopl fl">
104                                 <strong>专题景区介绍</strong>
105                             </div>
106                             <div class="zhuantitopr fl">
107                             </div>
108                         </div>
109                         <div class="zhuanticon cl">
110                             <div class="zhuanticonl fl">
111                                 <img alt="" src='<%# Eval("ScenicPicture") %>' style="width: 266px; height: 186px;" />
112                             </div>
113                             <div class="zhuanticonr fl" name='zhunti' style="border: 1px solid red;">
114                                 <div class="zhuanticonrtop cl ">
115                                     <strong>
116                                         <%# Eval("SpecialName") %>
117                                         景点推荐----<%# Eval("ScenicName") %></strong></div>
118                                 <div class="zhuanticonrcon cl">
119                                     <p class="fl" name="c">
120                                         <%# Common.HLString.Substring(Eval("ScenicInfo").ToString(),302) %>
121                                         <div class="alertFromInfo" style="display: none;">
122                                             <%# Eval("ScenicInfo").ToString() %>
123                                         </div>
124                                         <div class="alertFromInfo" style="display: none;">
125                                             <%#Eval("ScenicInfo") %>
126                                         </div>
127                                         ...</p>
128                                     <div id="divTest" class="fl">
129                                     </div>
130                                 </div>
131                             </div>
132                         </div>
133                     </div>
134                 </ItemTemplate>
135             </asp:Repeater>
136 
137             <script src="../js/jquery-1.4.1.min.js" type="text/javascript"></script>
138 
139             <script src="../js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
140 
141             <input type="button" id="ackd" value="sdfasdfasdddddddddddddddddddd" />
142 
143             <script type="text/javascript">
144             
145          $(function () {    
146          $("#ackd").click(function (){ alert("11");});
147 //                alert($("div[name='zhunti']").size());
148 //                alert($("div[name='zhunti']").eq(0).html())
149 //                alert($(".alertFromInfo").size());
150 //                alert($(".alertFromInfo").eq(0).html());
151 //              var $click= function () {
152 //                        
153 //                        $(this).find("p[name='c']").attr("style", " border:1px solid red; display:none");
154 //                        $(this).find("div.alertFromInfo").attr("style", "dispaly:block;");
155 //                            alert("zhuanticonrcon 加载事件 成功");
156 //                    }
157 //                  $("div[name='zhunti'] ").click(click);
158 //                  
159 //                    $("div[name='zhunti'] ").mouseover(function () {
160 //                        
161 //                        $(this).find("p[name='c']").attr("style", " border:1px solid red; display:none");
162 //                        $(this).find("div.alertFromInfo").attr("style", "dispaly:block;");
163 //                            alert("zhuanticonrcon 加载事件 成功");
164 //                    });
165 //                    $(".alertFromInfo").mouseout(function () {
166 //                        $(this).attr("style", "display:none;");
167 //                        $(this).parent().find("p[name='c']").attr("style", " display:block; border:1px solid blue;");
168 //                    });
169                 });
170             </script>
171 
172             <div class="cankao cl">
173                 <div class="cankaol fl">
174                     <div class="cankaoltop cl">
175                         <div class="cankaoltopl fl">
176                             <div class="canl fl">
177                                 <img src="img/y3_32.jpg" /></div>
178                             <div class="canr fl">
179                                 <strong>参考线路</strong></div>
180                         </div>
181                         <div class="cankaoltopr fl">
182                         </div>
183                     </div>
184                     <div class="cankaolcon cl">
185                         <asp:Repeater runat="server" ID="rpxianluList">
186                             <ItemTemplate>
187                                 <ul class="lists">
188                                     <li><a href='../Special/Line/<%# Eval("LineId") %>.html'>▪&nbsp;<%# Common.HLString.Substring(Eval("LineName").ToString(),50)%></a></li>
189                                 </ul>
190                             </ItemTemplate>
191                         </asp:Repeater>
192                     </div>
193                 </div>
194                 <div class="cankaor fl">
195                     <div class="cankaors cl">
196                     </div>
197                     <div class="cankaorz cl">
198                         <div class="contat cl">
199                             游客免费注册、免费发标、旅行社主动为您竞标比价格、比线路质量 、比服务在旅游招标网发布旅游需求标书,真正做到“省时,省心,省力,省 钱”。</div>
200                         <ul class="cl">
201                             <li><a href="http://www.nuoya114.com/MemberCenter/UI/Register.html">
202                                 <img src="img/y3_38.jpg" /></a></li><li><a href="http://www.nuoya114.com/MemberCenter/UI/fabiao.html">
203                                     <img src="img/y3_40.jpg" /></a></li></ul>
204                     </div>
205                     <div class="cankaorx cl">
206                     </div>
207                 </div>
208             </div>
209         </div>
210         <div class="cxxl cl">
211             <div class="cxxltop cl">
212                 <div class="cxxltopl fl">
213                     <div class="cxxltopl1 fl" id="m01">
214                         <strong>线路推荐</strong>
215                     </div>
216                 </div>
217                 <div class="cxxltopr fl">
218                 </div>
219             </div>
220             <div class="cxxlcon cl">
221                 <div id="c01">
222                     <asp:Repeater runat="server" ID="rptype" OnItemDataBound="rptype_ItemDataBound">
223                         <ItemTemplate>
224                             <ul>
225                                 <li class="typeBack"><strong>
226                                     <%# Eval("typename") %>
227                                 </strong>
228                                     <asp:Label runat="server" ID="lbltypeid" Text='<%# Eval("typeid") %>' Visible="false"></asp:Label></li>
229                                 <li style="overflow: hidden; width: 790px; height: 25px;">·
230                                     <asp:Repeater runat="server" ID="rpZT">
231                                         <ItemTemplate>
232                                             <a href='<%#Eval("Specialid") %>.html'>
233                                                 <%# Eval("SpecialName") %>
234                                             </a>
235                                         </ItemTemplate>
236                                     </asp:Repeater>
237                                 </li>
238                             </ul>
239                         </ItemTemplate>
240                     </asp:Repeater>
241                 </div>
242             </div>
243         </div>
244         <div class="yjgl cl">
245             <div class="yjgltop cl">
246                 <div class="yjgltopl fl">
247                     <div class="canl fl">
248                         <img src="img/y3_32.jpg" /></div>
249                     <div class="canr fl">
250                         <strong>游记攻略</strong></div>
251                 </div>
252                 <div class="yjgltopr fl">
253                 </div>
254             </div>
255             <div class="yjglcon cl">
256                 <asp:Repeater runat="server" ID="rptYouji">
257                     <ItemTemplate>
258                         <dl>
259                             <%--<dt>
260                                  <img src="images/<%# Eval("picture") %>" />
261                             </dt>--%>
262                             <dd>
263                                 <div class="xshang cl">
264                                     <div class="xshangl fl">
265                                         <a href='../Stratagem/<%# Eval("pid") %>.html'>·
266                                             <%# Eval("title") %>
267                                         </a>
268                                     </div>
269                                     <div class="xshangr fl">
270                                         [<%# Convert.ToDateTime(Eval("publicTime")).ToString("yyyy-MM-dd")%>]</div>
271                                 </div>
272                                 <div class="xxia cl">
273                                     <%# Eval("Detail")%>
274                                     ..
275                                 </div>
276                             </dd>
277                         </dl>
278                     </ItemTemplate>
279                 </asp:Repeater>
280             </div>
281         </div>
282         <div class="yjgl cl">
283             <div class="yjgltop cl">
284                 <div class="yjgltopl fl">
285                     <div class="canl fl">
286                         <img height="31px" src="img/try.png" /></div>
287                     <div class="canr fl">
288                         <strong>游客点评</strong></div>
289                 </div>
290                 <div class="yjgltopr fl">
291                 </div>
292             </div>
293             <div class="yjglcon cl">
294                 <asp:Repeater runat="server" ID="rptDianPing">
295                     <ItemTemplate>
296                         <dl class="yk">
297                             <dd>
298                                 <div class="xshang cl">
299                                     <div class="xshangl fl">
300                                         ·
301                                         <%# Eval("CommentTitle")%>
302                                     </div>
303                                     <div class="xshangr fl">
304                                         [<%# Eval("SendTime","{0:yyyy-MM-dd}")%>]</div>
305                                 </div>
306                                 <div class="xxia cl">
307                                     <%# Common.HLString.Substring(Eval("CommentContent").ToString(),298)%>
308                                     ..
309                                 </div>
310                             </dd>
311                         </dl>
312                     </ItemTemplate>
313                 </asp:Repeater>
314             </div>
315         </div>
316         <div class="yjgl cl">
317             <div class="yjgltop cl">
318                 <div class="yjgltopl fl">
319                     <div class="canl fl">
320                         <img src="img/w_62.jpg" /></div>
321                     <div class="canr fl">
322                         <strong>友情链接</strong></div>
323                 </div>
324                 <div class="yjgltopr fl">
325                 </div>
326             </div>
327             <div class="yjglcon cl">
328                 <asp:Repeater runat="server" ID="rptLink">
329                     <ItemTemplate>
330                         <ul>
331                             <li><a href="<%# Eval("LinkUrl") %>">
332                                 <%# Eval("LinkName")%>
333                             </a></li>
334                         </ul>
335                     </ItemTemplate>
336                 </asp:Repeater>
337             </div>
338         </div>
339         <div class="bottom cl">
340             <div class="index_footer">
341                 <div class="footer_img">
342                 </div>
343                 <p class="indexftmenu">
344                     <a rel="nofollow" href="<%=ResolveUrl("../common/about_us.html")%>">关于我们</a> | <a
345                         href="<%=ResolveUrl("../common/link_type.html")%>">联系方式</a> | <a rel="nofollow" href="<%=ResolveUrl("../common/falv.html")%>">
346                             版权声明</a> | <a href="<%=ResolveUrl("../common/links.html")%>">友情链接</a> |
347                     <a rel="nofollow" href="<%=ResolveUrl("../common/link_type.html")%>">意见反馈</a> |
348                     <a rel="nofollow" href="<%=ResolveUrl("../index.html")%>">返回首页</a> | <a href="#">返回顶部</a>
349                 </p>
350                 Copyright &copy; 2010&nbsp;&nbsp;&nbsp;All Rights Reserved.&nbsp;&nbsp;北京诺亚方舟旅游景区管理有限公司<br />
351                 版权所有 <a href="http://www.miibeian.gov.cn/" target="_blank" class="bottom_link">京ICP备11028652号-1</a>&nbsp;&nbsp;京公网安备
352                 110105010102&nbsp;&nbsp;<a href="../../images/icp证.png" target="_blank">京ICP证111013号</a><a
353                     href="http://new.cnzz.com/v1/login.php?siteid=3910958"><img alt="站长统计" src="<%=ResolveUrl("../images/icontj.gif")%>"
354                         style="background-color: White" /></a>&nbsp;<script type="text/javascript">
355 var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
356 document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F0a88b1b7259e63f5800080eba81520fc' type='text/javascript'%3E%3C/script%3E"));
357                         </script>
358 
359                 <div style="display: none">
360 
361                     <script src="http://s21.cnzz.com/stat.php?id=3910958&web_id=3910958&show=pic" type="text/javascript"
362                         language="JavaScript"></script>
363 
364                 </div>
365 
366                 <script type="text/javascript" id="bdshare_js" data="type=tools"></script>
367 
368                 <script type="text/javascript" id="bdshell_js"></script>
369 
370                 <script type="text/javascript">
371     document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?t=" + new Date().getHours();
372                 </script>
373 
374             </div>
375         </div>
376     </div>
377 
378     <script src="../js/jquery-1.4.1.min.js"></script>
379 
380     <script type="text/javascript" src="../js/return_top.js"></script>
381 
382     <script type="text/javascript" src="../js/tip.js"></script>
383 
384 </body>
385 </html>
Mundo Novo | 园豆:69 (初学一级) | 2012-06-27 14:07
其他回答(1)
0

用class取出的元素,可能有多个元素,也就是一个结合,而集合是不可以直接.mouseover,你试试each遍历然后添加mouseover试试看行不行。

收获园豆:5
Plusone | 园豆:344 (菜鸟二级) | 2012-06-27 16:17

谢谢 ,已经解决了。 是和其他JS文件冲突了

支持(0) 反对(0) Mundo Novo | 园豆:69 (初学一级) | 2012-06-29 21:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册