This is a working version: jsFiddle.
Did the following:
Instead of using the
href
to store the currency used a custom attributedata-targetCurrency
(this is better to prevent the behaviour of href):<a href="javascript: void(0);" data-targetCurrency="currencyeuros"><button class="btn btn-danger">
Instead of using
id
, used another custom attributedata-currency
:<div class="cc" data-currency="currencyeuros">€159</div>
Changed the javascript to:
jQuery("#menu a").click(function () { var currency = jQuery(this).attr('data-targetCurrency'); var showIt = jQuery("[data-currency=" + currency + "]"); var hideIt = jQuery(".cc.current"); hideIt.fadeOut(100, function () { hideIt.removeClass("current"); showIt.addClass("current"); showIt.fadeIn(100); }); });
NB:
The jQuery selector for an attribute is jQuery("[attributename = attributevalue]")