02-04-2010, 12:28 AM
|
#3 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
I know this isn't jQuery, but this should give you a good idea how to do it.
javascript Code:
// So that an element with the class 'a_parent' opens // 'a_child', and 'b_parent' opens 'b_child' etc.
function listen(parent_id, child_id) {
// Grab the base element to listen for var parent = document.getElementById(parent_id);
// Listen on that element for the click to open the child. parent.onclick = function (child_id) { // Grab and check the child's style. var child = document.getElementById(child_id); // You could check the .style.height, or .style.visibility if (child.style.display === 'none') { // Show the child element // You could use inline, inherit, or auto (CSS properties) child.style.display = 'block'; } else { // Hide the child child.style.display = 'none'; }
} }
|
|
|
|