Using labels in JQuery
<p>I am trying to use a <code>&lt;label&gt;</code> to show some text on a JQuery UI Dialog object.  But it always seems to lose the value.  Here is the code snippet where I am setting the value :</p>

<pre><code>function populateDialog(intMeterID) {

                  $.ajax(
                   {
                       type: "POST",
                       url: "/WS.asmx/GetMeterSettingsByMeterID",
                       data: "{intMeterID:" + intMeterID + "}",
                       async: false,
                       dataType: "json",
                       contentType: "application/json; charset=utf-8",

                       success: function(msg) {

                           var strMeterName = msg.d.MeterName;

                           $("label[for='lblMeterID']").text(intMeterID);
                           $("label[for='lblMeterName']").text(strMeterName);
</code></pre>

<p>And on a button click I am then trying to take the value from the label, but it is empty.  However, the msg.d.MeterName does contain the data!</p>

<pre><code>function saveMeterDetails() {

                   var intMeterID = $("label[for='lblMeterID']").text();
                   var strMeterName = $("label[for='lblMeterName']").text();
</code></pre>

<p>html:</p>

<pre><code>&lt;div id="dialog-form"&gt;
    &lt;div style="height: 200px; min-height: 109px; width: auto;" id="dialog"&gt;
        &lt;table&gt;
            &lt;tr&gt;
                &lt;td&gt;
                    &lt;label style="display:none;" for="lblMeterID" /&gt;
                    &lt;label style="font-weight:bold;" for="lblMeterName" /&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;/tr&gt;
            [...]
</code></pre>

<p>Any ideas why?</p>
