in my tree structure when a sibling is added (ul) (li) (div) span node name span (/div) (/li) ............... this strucutre goes on at one level when i add a child than the strucutre becomes like this
  (ul)
     (li)
       (div)
          span node name span(selected)
        (ul id="ul1")
        (li)
           (div)
              (span) child node name(/span)
           (/div)
        (/li)
开发者_开发知识库
     (/div)
....................... it goes on untill there is one more level added. the thing is that i want to get the id of child ul when the parent span is selected. get ul1 as result
When you select it you can grab it, for example:
$("span").click(function() {
  var ulID = $(this).siblings("ul").attr("id");
});
In your case it appears to be a sibling, so .siblings() would be appropriate.
for my it looks like you want to find the first ul as a child of a parent ul.
So try this:
$( 'ul' ).click( function() {
  console.debug( $(this).find('ul').attr('id') );
});
If the UL is a descendant of the span (which is how I understand this problem), you can do this:
$("span").click(function() {
    alert($(this).find("ul").attr("id"));
});
If the UL is always the very next sibling, you can use .next:
$(this).next("ul").attr("id");
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论