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

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

如何從 jQuery 元素中提取 href?

如何從 jQuery 元素中提取 href?

Go
Cats萌萌 2023-08-21 15:12:30
我正在嘗試從 html 元素中提取 href 和名稱。    var $row = $(this).closest("tr");     var $link = $row.find("td").eq(0).html();     var $website = ????     var $vendor = ????$鏈接返回<a href="https://<website>/" target="_blank">'vendor name'</a>我希望 $website 返回https://<website>/并且 $vendor 返回vendor name
查看完整描述

1 回答

?
慕哥6287543

TA貢獻1831條經驗 獲得超10個贊

var $row = $(this).closest("tr");

var $link = $row.find("td").eq(0).find('a'); // .html() returns a string, you don't want it. You want the jQuery reference of the link, so you can call jQuery methods on it

var $website = $link.attr('href');

var $vendor = $link.text();


查看完整回答
反對 回復 2023-08-21
  • 1 回答
  • 0 關注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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