I need a little help with the JS for this show/hide function
Essentially in the site there is PHP loop which echos out the HTML code below X-number of times.
I needed some JS to allow me to target each individual instance with a show/hide function, unfortunately my knowledge of JavaScript is low - I had some assistance from a developer with the code below but I seem to have gone wrong somewhere down the line as the console returns this error message "Uncaught SyntaxError: Unexpected identifier"
Any insight or help into this will be much appreciated!
Thanks in advance
The HTML
<span class="contentShow" >Dropdown Text Here...</span>
<a id="prod_more_trigger" ><span>More...</span></a>
The JS
<script type="text/javascript">
$(document).ready(function()
{
var i = 0;
$(document).find('span.contentShow').each(function() {
$(this).attr('data-id', i++);
$('span.contentShow').hide();
});
i = 0;
$(document).find('a.prod_more_trigger').each(function() {
$(this).attr('data-id', i++);
$(this).click(function() {
var $span = $(document).find('span.content[data-id="' + $(this).attr('data-id) + "]');
$('span.contentShow').toggle('fast');
});
});
});
</script>