Spoiler slideDown problem
3 posters
Page 1 of 1
Spoiler slideDown problem
I was trying to change my spoiler tag so that it slides down instead of toggles visibility with this custom jquery code:
Did I mess up on the targets or is doing such a thing impossible?
- Code:
$(".genmed").click(function() {
$(".spoiler_content").slideDown();
});
Did I mess up on the targets or is doing such a thing impossible?
jellalthesomewhatannoyed- New Member
- Posts : 2
Reputation : 1
Language : English
Re: Spoiler slideDown problem
Your problems not with the code, but possibly with the fact the other event listener is still attached, and so will execute at the same time... appearing as if the sliding is not happening.
What would need done would be to replace the spoilers with a clone, which removes all event listeners on it.
So it may be longer than you first thought:
Your code would also (if it had worked) toggled all the spoilers on the page at the same time, when only one is clicked.
What would need done would be to replace the spoilers with a clone, which removes all event listeners on it.
So it may be longer than you first thought:
- Code:
$(function(){
var s = $('.post .genmed');
for(var i = 0, l = s.length; i<l; i++) {
$(s[i]).replaceWith(s[i].cloneNode(true));
}
$('.post .genmed').click(function() {
$('.spoiler_content', this.parentNode).slideDown();
});
});
Your code would also (if it had worked) toggled all the spoilers on the page at the same time, when only one is clicked.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Spoiler slideDown problem
Unfortunately that seemed not to have fixed it
jellalthesomewhatannoyed- New Member
- Posts : 2
Reputation : 1
Language : English
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum