javascript - Get the index of the parent element, by finding the childs data-id -


is possible knowing child's data-id find().index() on parent? code such:

<div class="owl-wrapper" style="width: 38640px; left: 0px; display: block;">     <div class="owl-item" style="width: 280px;">         <div class="itemchild" data-remid="67">         </div>     </div>     <div class="owl-item" style="width: 280px;">         <div class="itemchild" data-remid="135">         </div>     </div>     <div class="owl-item" style="width: 280px;">         <div class="itemchild" data-remid="136">         </div>     </div> </div> 

i want index of itemchild element, contains chile specific data-remid

something like: .find("[data-remid='" + id + "'"]).parent().index();

you haven't handled quotes correctly while making selector. use:

$("[data-remid=" + id + "]").parent().index(); 

working demo


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -