Saturday 15 September 2012

javascript - jquery slide toggle : hidden + new link -


Toggle open and to add the "show" link to add to the toggles I should include in jquery below To be able to "Bleblabla" at the end of the "Close" link) (keeping in mind the slow effects)

jQuery:

  var $ j = JQuery .noConflict (); $ J (function () {$ j ('# containertoggle'). ('Click', 'a.opener', function () {$ j (this) .next () toggle ('slow'}}); });   

HTML: & lt; Ul id = "containertoggle" & gt; & Lt; Li & gt; & Lt; One class = "opener" & gt; Show & lt; / A & gt; & Lt; Div style = "display: none;" & Gt; & Lt; P & gt; Blablablabla & lt; / P & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; One class = "opener" & gt; Show & lt; / A & gt; & Lt; Div style = "display: none;" & Gt; & Lt; P & gt; Blablablabla & lt; / P & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; / Ul & gt;

You can try this approach.

Also, better idea to avoid adding styles to style attribute instead use classes.

  var $ j = jQuery.noConflict (); $ J (function () {$ j ('#contentagogue'). ('Click', 'a.opener', function) {var $ this = $ j (this); $ this.next ('div') ('Slow'); $ this.nextAll ('a.closer') first (). RemoveClass ('hide'); $ this.addClass ('hide');}); $ J ('#' ('click', 'acloser', function) (var $ this = $ j (this); $ this.prev ('div'). Hide ('slow'); $ this prev ('A.opener'). First (). RemoveClass ('hide'); $ this.addClass ('hide');});});   



No comments:

Post a Comment