I have a dropdown that is configured to go to the respective div location on the page when it is selected. My question is, how do I add another part to the javascript to add a specific class to that div, and remove a current one? Also, I need to fix my GA event tracking on the last 'link'/option in the select menu-- it drives to a subdomain so I need to use the gaq_push 'link' function-- however what I have now isn't working out.
here is the URL for reference: (resize window to <480px to see see 'select' menu functionality): here
Here is the html:
<select id="aloha">
<option selected="selected" value="">Go to...</option>
<option value="#overview">Overview</option>
<option value="#Fat">Fat Burning</option>
<option value="#Energy">Energy & Endurance</option>
<option value="#Vitamins">Vitamins & Antioxidants</option>
<option value="#faq">FAQ</option>
<option value="#Facts">Supplement Facts</option>
<option value="http://store.uniconutrition.com/product-p/1002-unico-toned-raz.htm">Buy Now</option>
</select>
and the JS:
$(".mobster select").change(function() {
window.location = $(this).find("option:selected").val();
});
});
$("#aloha").change(function(){
if($(this).val() == "http://store.uniconutrition.com/product-p/1002-unico-toned-raz.htm") {
_gaq.push(['_trackEvent', 'toned select', 'Click', 'Buy'], ['_link', 'http://store.uniconutrition.com/product-p/1002-unico-toned-raz.htm']); return false;
} else {
_gaq.push(['_trackEvent','toned select','Click',this.selectedIndex.toString()]);
}
});