I want to replace the HREFs in a list with new URLs.
I have something like this:
<ul id="sidebarItems">
<li><a href="/PartBasicInfo/XX">Part Basic Info</a></li>
<li><a href="/SupplierContracts/XX">Supplier Contracts</a></li>
</ul>
I’m trying this (I know there are lots of ways to do it), but not having any luck. Any ideas?
function SetUrlParams() {
$("#sidebarItems > li > a").each(function (idx, a) {
a.attr("href", "MyURLOfChoice");
});
The second parameter is the DOM element, not the jQuery element, wrap
awith$(a)Or leave jQuery for this simple task:
Note that you can access the DOM element with
thisinstead ofa.