I don't want to repeat my code so I am trying to figure out how to work with a click event on multiple elements:
$(document).ready(function() {
var realStateBtn = $('#real-estate-center').parent();
var link = $('#real-estate-center > .linkwidth');
realStateBtn.css('zIndex', 9999);
realStateBtn.click(function() {
console.log('TRIGGERED');
window.location.href='http://realestatecenter.bankofamerica.com/';
});
link.click(function() {
window.location.href="http://realestatecenter.bankofamerica.com/";
});
});
as you see the vars realStateBtn and link take you to the same place/has the same function applied so what can I do in order to put the same code into one function?
I know I can do something like this:
$('.class1, class2').click(...)
but in this case I have this elements:
$('#real-estate-center').parent();
$('#real-estate-center > .linkwidth');
Suggestions?