[eluser]treadsoftley[/eluser]
First dabbles with jquery and I wanted to have a news listing page with multiple show/hide the news body. I found this (@ :http://ok-cool.com/posts/read/17-jquery-for-designers-part-2/)
Code:
<scr+ipt> //<![CDATA[
// When the page is ready
$(document).ready(function(){
$(".article .thebody").hide();
$("#container .article ul")
.prepend("<li class='readbody'><a href='' title='Read the article'>Read Body</a></li>");
$(".actions li.readbody a").click(function(event){
$(this).parents("ul").prev(".thebody").toggle();
// Stop the link click from doing its normal thing
return false;
});
});
//]]></scr+ipt>
And it worked just fine. But I wanted to toggle 'read' to 'hide' once it was clicked etc.
so I added this:
Code:
<scr+ipt> //<![CDATA[
// When the page is ready
$(document).ready(function(){
$(".article .thebody").hide();
var readMe="read";
var hideMe="hide";
$("#container .article ul")
.prepend("<li class='readbody'><a href='' title='Read the article' id='readHide'>"+readMe+"</a></li>");
$(".actions li.readbody a").click(function(event){
$(this).parents("ul").prev(".thebody").toggle();
if ($('a#readHide').text()==readMe) {
$('a#readHide').text(hideMe);
}
else {
$('a#readHide').text(readMe);
}
// Stop the link click from doing its normal thing
return false;
});
});
//]]></scr+ipt>
But of course this changed every 'read' on the page to 'hide' not just on the specific item. How can I make this item/record specific?