tags with an existing href attribute: In case you want to match an anchor with a specific existing href, then you can do the following: Then you should update only some part of the href attribute: The first part only selects links where the href starts with http://stackoverflow.com. jQuery: Set href attribute at runtime Last update on February 26 2020 08:07:52 (UTC/GMT +8 hours) Using jQuery's .attr() method to get the value of an element's attribute has two main benefits:. This event is limited to elements,