PDA

View Full Version : jQuery Spoiler Help


James Birkett
08-04-2009, 09:50 PM
I'm coding a spoiler using jQuery. I have an error though.
I know the error, I just can't re-code it to fix it! Frustration :(

<style type="text/css">
p#spoilercontent{
display:none;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('p#spoiler').click(function() {
$('p#spoilercontent').toggle(400);
});
});
</script>
<div align="center">
<strong><p id="spoiler"><u>Spoiler:</u></strong><br />
<p id="spoilercontent">{param}</p>
</div>


That's my code, and the problem is it's controlling all spoilers not that one. I need to use $(this). but I can't re-code it to use that.

Any help is appreciated.

1Unreal
08-05-2009, 06:36 AM
You need to use "this".

http://css-tricks.com/fade-in-spoiler-revealer/

James Birkett
08-05-2009, 03:41 PM
I know I need to use $(this), I just can't recode it to use it. I'm stumped

MrC_53
09-24-2009, 03:02 PM
Dude, the code are ok, i put the code in my forum and work perfectly

what is your problem?

James Birkett
09-24-2009, 06:05 PM
This is an old thread, I forgot I posted it :rolleyes:

The problem is that when clicked it toggles all ID's of spoiler within the paragraph tag, and not the one that is clicked.

It needed to be re-coded using ($this), which I never got round to doing.