How can I search through parents in jquery?
satya - Sun Oct 14 2012 08:46:57 GMT-0400 (Eastern Daylight Time)
Here is a quick run down on selectors:my original notes on jquery
Here is a quick run down on selectors:my original notes on jquery
satya - Sun Oct 14 2012 08:47:21 GMT-0400 (Eastern Daylight Time)
A note from jquery forum
satya - Sun Oct 14 2012 08:47:35 GMT-0400 (Eastern Daylight Time)
How can I search through parents in jquery?
How can I search through parents in jquery?
satya - Sun Oct 14 2012 09:17:50 GMT-0400 (Eastern Daylight Time)
You can do this with closest
$(linkElement).closest("div.manage_expanded").hide();
satya - Sun Oct 14 2012 09:18:27 GMT-0400 (Eastern Daylight Time)
Here is the API doc for it
satya - Sun Oct 14 2012 10:02:26 GMT-0400 (Eastern Daylight Time)
Here is an example
<script>
function showManage(linkElement)
{
var manageDiv = $(linkElement).closest("div.manage");
var expandedManageDiv = manageDiv.siblings("div.manage_expanded");
expandedManageDiv.show();
manageDiv.hide();
//return false;
}
function hideManage(linkElement)
{
var expandedManageDiv = $(linkElement).closest("div.manage_expanded");
var manageDiv = expandedManageDiv.siblings("div.manage");
expandedManageDiv.hide();
manageDiv.show();
//return false;
}
</script>
<div class="manage">
<p>
<a href="javascript:void(0)" onClick="javascript:showManage(this)">Manage</a>
</p>
</div>
<div class="manage_expanded" style="display:none">
<p>
<a href="javascript:void(0)" onClick="hideManage(this)">Hide</a>
<a href="">Folder</a>
<a href="">xml</a>
<a href="">template</a>
</p>
</div>
satya - Sun Oct 14 2012 10:02:40 GMT-0400 (Eastern Daylight Time)
This uses siblings method as well
This uses siblings method as well
satya - Sun Oct 14 2012 10:03:03 GMT-0400 (Eastern Daylight Time)
Here are all the tree traversal methods from jquery