سؤال

I have this elements hierarchy :

<div>
   <div>
      <input id="abc" .../>
   </div>
   <div>
      <span />
   </div>
</div>

How can I access to span element via input whom I know id please ?

I think I have to use

$("#abc").parent().parent()...

...but after please ?

Thank you

هل كانت مفيدة؟

المحلول

try this

$("#abc").parent().next().children('span')

demo

نصائح أخرى

Try this,

Live Demo

var spanElement = $('#abc').parent().next().find('span');
$("#abc").parent().next().children('span')
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top