Which JavaScript code segment should you use?

You are developing a customer web form that includes the following HTML.
<label id=”txtValue”X/label>
Information from the web form is submitted to a web service. The web service returns the following
JSON object.
{
“Confirmation”: “1234”,
“FirstName”: “John”
}
You need to display the Confirmation number from the JSON response in the txtValue label field.
Which JavaScript code segment should you use?

You are developing a customer web form that includes the following HTML.
<label id=”txtValue”X/label>
Information from the web form is submitted to a web service. The web service returns the following
JSON object.
{
“Confirmation”: “1234”,
“FirstName”: “John”
}
You need to display the Confirmation number from the JSON response in the txtValue label field.
Which JavaScript code segment should you use?

A.
$(“#txtValue”).val = (JSONObject.Confirmation);

B.
$(“#txtValue”).val (JSONObject.Confirmation);

C.
$(“#txtValue”).text = (JSONObject.Confirmation);

D.
$(“#txtValue”).text (JSONObject.Confirmation);

Explanation:

Reference:
http://api.jquery.com/text/



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Firefox360

Firefox360

1: (“#txtValue”) selects the element with the id=”txtValue”.
2: A label has the .text(“string”) property, where the input-element has the value property. So D ($(“#txtValue”).text (JSONObject.Confirmation);) is the correct answer.