I'm working with a client and I'm only allowed to use javascript (don't ask why as I have no idea). They don't have jquery setup and they don't want it (once again I have no idea why)
Anyways there is a link on the page that they want to change the href to on page load. Below is the link structure.
<a class="checkout_link" title="Checkout" href="current_url">Checkout</a>
I was wondering if there is any way to change the href on page load using basic javascript for the link above? If so how would I go about doing it?
Thanks
getElementsByTagName()
and searching the resulting array), you will want to do thisonDOMLoad
instead ofonload
... which needs additional code to work across browsers. jQuery or some other library would make this really easy. – Scholarship<a>
that you wish to change? – Nutpick.hasClass()
that works for multiple classes (class="navigation checkout_link"
) which is also not completely trivial. But the OP may not need that – Scholarship