Is is better to set up data before click or onclick?
Bit of a jquery noob.
I have a simple function that replaces the href content on a link with that of a data attribute.
The function looks for the class click-reveal and performs the action.
I'm unsure of which is the best route, 1) call a function that replaces all in my page load function, or 2) do it onclick with a redirect.
A code sample for the second variation is shown below.
- var gotoOutPage = function (e) {
pd(e);
var url = $(this).data('url');
$(this).attr("href", url)
window.location = $(this).attr('href');
}
Thanks in advance.