亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Firebug上的一個bug

Firebug上的一個bug

hhhzihao2 2016-05-10 19:17:08
<!DOCTYPE html><html><head>? <meta charset="utf-8">? <script type="text/javascript" src="jquery-1.12.js"></script>? <script type="text/javascript">??? $(function () {???? ?????? $('img').mousemove(function () {??????? $('img').each(function() {????????? var str = $(this).attr('src').replace('4','2').replace('3','1');????????? $(this).attr('src', str);??????? })??????? $(this).nextAll().each(function () {???????? ?????????? var str = $(this).attr('src').replace('2','4').replace('1','3');????????? $(this).attr('src', str);??????? })????? })??? })? </script></head><body>? <img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif"><img src="stars/rank_3.gif"><img src="stars/rank_4.gif">? <p></p></body></html>如果有<p></p> , 就會提示否則正常 , 這是為什么 ? 這會影響程序運行嗎 ?
查看完整描述

1 回答

已采納
?
花滿樓的小前端a

TA貢獻79條經驗 獲得超33個贊

$(this).nextAll()會選中這個p元素,而這個p元素沒有src屬性,所以就出現undefined.replace()了;

可以這樣$(this).nextAll().not('p').each()或$(this).nextAll('img').each()

查看完整回答
1 反對 回復 2016-05-11
  • 1 回答
  • 0 關注
  • 1123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號