Hi guys,
Totally new to jQuery and I'm stuck. Trying to get mulitple things to happen when <a class='ppfm'></a> is clicked to show the user an animated loading .gif while PayPal takes an age to load the next page. This makes sense logically, but for some reason doesn't work...
jQuery:
$(function() {
$('a.ppfm').click(function() {
$('this').css('background','#FF0000');
$('this').sibling('.buy').hide();
$('this').sibling('.wait').show();
$('this').parent('.form').submit(); return false;
});
});
css:
.wait {display:none;}
simplified page:
<form class='form' action="paypal" method="post">
<input><input><input>
<a href="#" class='ppfm'><span class='buy'>Buy</span>
<span class='wait'><img src='/images/wait.gif' width='30' height='30' alt=""></span>
</a>
</form>
<form class='form' action="paypal" method="post">
<input><input><input>
<a href="#" class='ppfm'><span class='buy'>Buy</span>
<span class='wait'><img src='/images/wait.gif' width='30' height='30' alt=""></span>
</a>
</form>
<form class='form' action="paypal" method="post">
<input><input><input>
<a href="#" class='ppfm'><span class='buy'>Buy</span>
<span class='wait'><img src='/images/wait.gif' width='30' height='30' alt=""></span>
</a>
</form>
Now, this works...
$(function() {
$('a.ppfm').click(function() {
$('this').css('background','#FF0000');
$('.buy').hide();
$('.wait').show();
$('.form').submit(); return false;
});
});
...but it obviously hides/shows all spans and submits all forms. I've tried a million different ways of doing it including .find() .next() and nothing seems to work apart from duplicating everything with multiple versions of the jQuery/css/page code for ppfm1, ppfm2, buy1, buy2, etc. That's fine, but it's a lot of extra code for something that should be easy to simplify based on 'this'.
Any help very much appreciated.
ory.