0

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Olivier J.
  • 3,115
  • 11
  • 48
  • 71

3 Answers3

1

Try this,

Live Demo

var spanElement = $('#abc').parent().next().find('span');
Adil
  • 146,340
  • 25
  • 209
  • 204
1

try this

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

demo

YogeshWaran
  • 2,291
  • 4
  • 24
  • 32
1
$("#abc").parent().next().children('span')
st3inn
  • 1,556
  • 9
  • 17