cesy: "Cesy" - An old-fashioned quill and ink (Default)
Cesy ([personal profile] cesy) wrote in [site community profile] dw_dev_training2009-09-21 08:05 am
Entry tags:

Javascript help

I am trying to implement a solution to Bug 581, and I need to do some Javascript that will make a hidden section appear when clicked on. So far I have this:

$out .= "Click here to see all your tags";
$out .= "


(and then the actual content in the span). What should my ShowTags() function actually do in order to change the style to display:inline? I found one example on the web, but it used fancy browser-sniffing, and it appears we have our own browser-sniffing module and I don't know how to adapt it for that.
janinedog: (Default)

[personal profile] janinedog 2009-09-21 03:06 pm (UTC)(link)
Yup, and actually if using LJ's JS, you can use $('divid') instead of document.getElementById('divid').

But the general idea is to have the div have a display: hidden; property, and have the onclick handler for the div do $('divid').style.display = 'block'; (or 'inline', depending on how you want it to look). If you want it to be able to toggle off again, just have your JS check to see if the div is hidden or shown first (by looking at the $('divid').style.display property), and then do the opposite.