0

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 &amp; Endurance</option>
<option value="#Vitamins">Vitamins &amp; 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()]);
    }
});
lance smith
  • 75
  • 3
  • 19
  • A few references from a quick Google search: http://stackoverflow.com/questions/10659097/jquery-get-selected-option-from-dropdown http://api.jquery.com/addClass/ http://api.jquery.com/removeClass/ – Mike Jul 18 '13 at 19:23
  • are you trying to add a class to the option elements or a div on the paeg? – Chris G-Jones Jul 19 '13 at 04:31

0 Answers0