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

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

如何獲取點擊元素的值

如何獲取點擊元素的值

一只甜甜圈 2023-09-25 16:22:37
我試圖通過 jQuery 在每次單擊錨標記“show”時獲取 li 元素的文本(1、2、3...),但似乎無法使其工作。這就是我正在處理的:HTML:<ul><li class="item_id">1</li><a class="show" href="#">SHOW</a></ul><ul><li class="item_id">2</li><a class="show" href="#">SHOW</a></ul><ul><li class="item_id">3</li><a class="show" href="#">SHOW</a></ul>JavaScript:/**This shows all values on each click and not only the current one**/$("a.show").click(function(){  $('li.item_id').each(function() {      var item_id = $(this).text();          alert(testimonial_id);                            });});/**This shows the first value on each click and not only the current one**/$("a.show").click(function(){    var item_id = $("li.item_id").text();    alert(item_id);});提前致謝!
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 140 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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