Solved by inet411 HowTo pass a dynamic variable to function
Hi all, newbie here.
I have a bit of php that creates an entry on a page for each row in a table, some pages may have multiple entries, others just one.
eg.
-
<h2 class="title">{title}</h2>
{summary}
<p onclick="openBox({entry_id})">Click to read more ></p>
<div id="{entry_id}" style="display:hidden;">{body}</div>
I would like to have just one function to open and close all individually, eg.
-
$(document).ready(function(){
function openBox(id){
if ($("#id:first").is(":hidden")) {
$("#id").slideDown("slow");
} else {
$("#id").slideUp("fast");
}
});
});
Well I know I'm doing something wrong as this is not working, and I don't know how better to explain I hope this is sufficient, I'm not worrried about the php/html bit as that is working fine.
I hope you can help, or ask the right questions so that I can give more accurate answers.
Many Thanks
Ron