Change (Set) Text of Label and TextBox in jQuery

Last Reply 8 months ago By dharmendr

Posted 8 months ago

How can change the text of a label bootstrap dynamically.

I need for the lblPreIni control, I implemented it by changing the name to the control, but it doesn't work.

$('#<%=txtPrecioIni.ClientID %>').text('Precio Inicial:');
Or
$('#<%=txtPrecioIni.ClientID %>').html('Precio Inicial:');

Any idea how i can do it?

cheers

<div class="form-group">
    <label id="lblPreIni" runat="server"  for="MainContent_text_reg_telefono" class="col-sm-4 control-label">Precio Inicial:</label>
    <div class="col-sm-8">
        <asp:TextBox ID="txtPrecioIni" Class="form-control"  runat="server" Height="27px" ></asp:TextBox>
    </div>
</div>
Posted 8 months ago

Hi jmontano,

For Label control you have to use .html() and for TextBox you have to use .val() attribute.

Example:

For Label

$('#<%=lblPreIni.ClientID %>').html('Precio inicial:');

For TextBox

$('#<%=txtPrecioIni.ClientID %>').val('Precio Inicial:');