javascript - How to find closest <i>? -


my html code follow :

  <div class="listitems">          user1@mail.com     <a style="float: right;vertical-align: top;" data-recom-user="3" data-recom-mile="4">       <i class="icon-eye-open"></i>     </a>     <i style="float: right;vertical-align: top;" data-irecom-done="false" data-irecom-user="3" data-irecom-mile="4" class="icon-hand-up" title="recommend user"></i>     </div> 

i have trigger click event on <a> in event handler function want access closest <a>

i tried $(this).closest("<i>") in got <i class="icon-eye-open"></i> how can

<i style="float: right;vertical-align: top;" data-irecom-done="false" data-irecom-user="3" data-irecom-mile="4" class="icon-hand-up" ></i> 

element can change some attributes of it.

based on html markup, can use siblings() or next() instead:

$(this).siblings('i') 

or:

$(this).next() 

also, note closest() traverse dom tree, method not using find child elements


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -