簡體   English   中英

jQuery-將Label的文本值嵌入到anchor href屬性中

[英]Jquery - Embedding Label's text value into anchor href attribute

我希望在Google上搜索$("#lblCompany").text() 如何將其嵌入下面? 嘗試<a href='https://www.google.com.tr/search?q='" +$("#lblCompany").text()+ "' 沒用 重定向到https://www.google.com.tr/webhp

$(".block1").bind('mouseenter', function (e) {
    $("#plus").append("<a href='https://www.google.com.tr/search?q=' target='_blank'");
}

單擊鏈接時,您需要重定向到href。

$('#lblCompany').on('click', function(e){
    e.preventDefault();
    $(this).attr('href', $(this).attr('href') + $(this).text());
    window.location = $(this).attr('href');
});

希望對您有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM