简体   繁体   中英

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

I want $("#lblCompany").text() to be searched on Google. How can I embed it below? Tried <a href='https://www.google.com.tr/search?q='" +$("#lblCompany").text()+ "' . Didn't work. Redirecting to https://www.google.com.tr/webhp

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

You need to redirect to href when click on the link.

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

Hope helps you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM