-1
<div id="FullName">
  <input type="text" id="FirstName" value="Srinath"/>
  <input type="text" id="LastName" value="Reddy"/>
</div>

How to retrive the value of firstName of div1 I want to print the value Srinath.

4 Answers4

0

HTML ids are supposed to be unique, and you should always try not to duplicate them. If you reeally want to do that you can do it with the css element in element selector like that:

$("#FullName1 #FirstName")
mdatsev
  • 3,054
  • 13
  • 28
0

You can get the value like this:

var firstName = document.getElementById('FirstName').value;
alert(firstName);
<div id="FullName">
  <input type="text" id="FirstName" value="Srinath"/>
  <input type="text" id="LastName" value="Reddy"/>
</div>

You can get it also by jQuery like this:

$('#FirstName').val()
zb22
  • 3,126
  • 3
  • 19
  • 34
0

Please check this:

$("#FullName input#FirstName").val(Text);

Karunakar
  • 1
  • 1
0

If in your scenario, you always want to get value of first input control in your div having specific id, then you can use following

$("#FullName>input").val()

Output: Srinath

SSD
  • 1,373
  • 2
  • 13
  • 20