jquery ui - Hiding a span in an accordion -


i need in hiding/unhiding neighboring spans. i'm building series of faqs using accordion structure. need have each question truncated default, when clicked, question must appear in full. finally, when open faq (or one) clicked, question should return truncated form.

my markup of form - have placed truncated version of question in 1 span , untruncated version in neighboring span:

> <div class="accord"><h4><span class="shortver">what steps need > take ...</span><span class="longver hide">what steps need > take install constructed wetland?</span></h4><div > class="faqcontent">answer goes here</div>...</div> 

the following function controls faq:

function fnsetuppagefaqaccordion(){   $(".accord > div").hide();   $(".accord > h4").click(function(){              $(this).find('span.shortver').addclass("hide").next('span.longver').removeclass('hide');   $(this).toggleclass("close").siblings("h4.close").removeclass("close");   $(this).next("div").slidetoggle("1500").siblings("div:visible").slideup("1000");return;   }); }; 

this code closes truncated version of question , opens full version when faq clicked. can't figure out how reverse sequence when faq clicked again (or faq on page clicked).

any suggestions - perhaps there better approach altogether?

thanks/bruce

here's different approach, , solution. think simplify this. instead of having 1 span short version , 1 long version, put beginning of explanation in first (let's call class="questionstart")and rest of in second (class="questionend"). way can leave beginning visible , worry toggling class on second. simpler you'd need remove '...' may not worth readability loss.

to address issue of hiding element when clicking else, try adding onclick event first adds hide class of "questionend" spans, toggles on 1 you've clicked on. haven't tried think make work pretty either original approach or mine.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -