<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var pValue = $(".blah").find("p").html();
alert(" Information in Paragraph tag is ### " + pValue);`enter code here`
$(".blah").find($("input:text")).each(function(){
alert("Value inside the Input text field is #### " + this.value);
});
});
</script>
</head>
<body>
<div class="blah">
<p>he he he</p>
<input "type = text name ="userName" value = "abc"/>
<input "type = text name ="id" value = "xyz"/>
</div>
</body>
</html>
Question:
When i run the above HTML code i get the following alerts
- Information in Paragraph tag is ### he he he
- Value inside the Input text field is #### abc
- Value inside the Input text field is #### xyz
I want to retrieve the input text field names (username and id) and place it in the alerts dynamically so that my alerts look as shown below. I want this functionality because if the user enters his username and not the id. i want to display that his id is empty.
- Information in Paragraph tag is ### he he he
- Value inside the userName is #### abc
- Value inside the id is #### xyz
Thanks a lot in advance.