The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Spoiler slideDown problem

3 posters

Go down

Spoiler slideDown problem Empty Spoiler slideDown problem

Post by jellalthesomewhatannoyed June 10th 2012, 13:37

I was trying to change my spoiler tag so that it slides down instead of toggles visibility with this custom jquery code:
Code:
$(".genmed").click(function() {
$(".spoiler_content").slideDown();
});
Although that seems to have no effect on it.
Did I mess up on the targets or is doing such a thing impossible?
avatar
jellalthesomewhatannoyed
New Member

Posts : 2
Reputation : 1
Language : English

Back to top Go down

Spoiler slideDown problem Empty Re: Spoiler slideDown problem

Post by +Fusion- June 10th 2012, 18:55

.onclick
+Fusion-
+Fusion-
Forumember

Male Posts : 252
Reputation : 4
Language : English
Location : Flying

http://www.xcodezz.com

Back to top Go down

Spoiler slideDown problem Empty Re: Spoiler slideDown problem

Post by LGforum June 10th 2012, 19:20

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:

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();
  });
});
Try that and see if it works.

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
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Spoiler slideDown problem Empty Re: Spoiler slideDown problem

Post by jellalthesomewhatannoyed June 12th 2012, 12:40

Unfortunately that seemed not to have fixed it
avatar
jellalthesomewhatannoyed
New Member

Posts : 2
Reputation : 1
Language : English

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum