How to update (append to) an href in jquery?

后端 未结 4 583
悲&欢浪女
悲&欢浪女 2020-11-27 15:19

I have a list of links that all go to a google maps api.

the links already have the daddr (destination) parameter in them as static. I am using Geo-Loca

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 16:00

    var _href = $("a.directions-link").attr("href");
    $("a.directions-link").attr("href", _href + '&saddr=50.1234567,-50.03452');
    

    To loop with each()

    $("a.directions-link").each(function() {
       var $this = $(this);       
       var _href = $this.attr("href"); 
       $this.attr("href", _href + '&saddr=50.1234567,-50.03452');
    });
    

提交回复
热议问题