i didn’t get any error message, its work fine, but this code its for tree menu when i click on item one its open the tree and when i click on another item its still open tree one and open tree two, what i want on click on another item hide all tree and open tree what i clicked.
For me it’s a lot easier and I would use less code by doing it with plain javascript, rather than with jquery. Hopefully someone else will come long if you must use jquery.
Bad webdev, he’s using jQuery for his existing code so he might as well continue to benefit from the library that he’s currently using.
He can loop through all of the elements that have an id starting with “parent_”
In that loop he can check if the element has a matching id number that was initially passed in, so that different behaviour can be performed with those that match.
It might be something like this:
$('[id^="parent_"]').each(function () {
if (this.id.split('_')[1] == id) {
// show this element
} else {
// hide this element
}
}