Hi folks.
I'm playing about with jQuery at the moment but I really don't have any js knowledge so I am going mostly by guess work. I ordered 2 js books yesterday though so I should be able to at least start learning the basics in a few days.
I am using the jQuery 'toggle' function and got it working nicely.
<script type='text/javascript' src='http://code.jquery.com/jquery-latest.js'></script>
<p id='block1'>Click Me</p>
<p id='toggle1'>The visibility of this gets toggled</p>
<script type='text/javascript'>
$('#block1').click(function () {
$('#toggle1').toggle('slow');
});
</script>
This works fine if I have a single block of elements to toggle but if I have multiple blocks of <p> (dynamically generated, this code is inside a foreach loop), and I want to have separate toggling in each block, I need to increment the id (block1 to block2 and toggle1 to toggle2 etc). I can use PHP to break the HTML statement and insert a variable to increment the id in the <p> tags but how do I increment the id in the javascript?
I hope I managed to explain this well enough for people to understand what I'm talking about :confused:
Zagga