I have this jQuery code that I wrote to load a plugin I've been developing.
I'm fairly new to this so this question might seem a little basic but I just can't get my head around how to clean up this code? Is there a way to reduce this into something a little lighter?
Basically 'a' shows the div (target) and .mv, .sb & .sl are all classes of 'a' tags. Depending on which link is click will depend on what displays (the spot_id changes the data loaded from the plugin).
The code works fine but I'm sure there's an easier way to write this. Thanks in advance!
$('a').click(function () {
$(this).attr("href");
});
$('.mv').click(function () {
$(this).surfplugin({
spot_id: 1
});
});
$('.sb').click(function () {
$(this).surfplugin({
spot_id: 2
});
});
$('.sl').click(function () {
$(this).surfplugin({
spot_id: 3
});
});
HTML:
<ul class="nav">
<li class="mavericks">
<a href="#display" class="mv">Mavericks</a>
</li>
<li class="santa-barbara">
<a href="#display" class="sb">Santa Barbara</a>
</li>
<li>
<a href="#display" class="sl">Steamer Lane</a>
</li>
</ul>
<div class="content">
<section id="display" class="beach"></section>
</div>