Category: Uncategorized

expand collapse with jquery

If you have a text that you want to hide and show to a click of a hide/show, put this code fast: ( instead of @Url.Content you can use <%=ResolveUrl ) [code lang="HTML"] <a href="javascript:ShowHide('the_id_of_the_element_to_be_show_or_hide', this)"> <img border="0" src='@Url.Content("~/Content/images/show.gif")' title = 'show hide'> </a> <div id='the_id_of_the_element_to_be_show_or_hide' style='display:hidden'> this is hidden content - will be displayed </div> [/code] [code lang="Javascript"] <script type="text/javascript"> var imgShow = '@Url.Content("~/Content/images/show.gif")'; var imgHide = '@Url.Content("~/Content/images/hide.gif")'; function ShowHide(id, img) { var element = $("#" + id); element.toggle('slow', function () { if (":hidden")) { img.src = imgShow ; } else { img.src = imgHide ; } } ); } </script> [/code]

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.