Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  157] [ 6]  / answers: 1 / hits: 65294  / 14 Years ago, wed, january 19, 2011, 12:00:00

I have two divs nested like so:



<div id=upper>
<div id=lower name=moo>
</div>
</div>


How would I, using jQuery or JavaScript alone, can I get the name of that lower nested div?


More From » jquery

 Answers
6
var nameValue = $('#lower').attr('name');


But if you really want to use the outer div to select the inner one:



var nameValue = $('#upper > div').attr('name');


Or



var nameValue = $('#upper #lower').attr('name');


Or



var nameValue = $('#upper').find('#lower').attr('name');

[#94138] Tuesday, January 18, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorr

Total Points: 193
Total Questions: 86
Total Answers: 105

Location: Pitcairn Islands
Member since Thu, Jun 24, 2021
3 Years ago
victorr questions
Fri, Nov 13, 20, 00:00, 4 Years ago
Sat, Jul 25, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;