How to pass value to label in modal

2

I fill in the inputs of my modal, as follows:

<input type="text" id="txtDescricao" name="txtDescricao" minlenght="4" required>   

Script:

modal.find('.modal-body input[name="txtDescricao"]').val(descricao)

And when I have a label, like:

<label for="teste"></label>

How do I pass the value of the description variable to it?

    
asked by anonymous 15.12.2015 / 11:26

2 answers

3

Just pass the delimiter in case the id of your input:

var novoLabel = $('#textoDescricao').val();
$("#teste").text(novoLabel);

So you would not use this "modal.find", just look for the element's delimiter and pass it via jQuery.

In your case, because it is a label you must use .text() because it takes the text of your label and modifies it by the new value, if it was a input you should use .val()

Follow a jsFiddle with the example: link

    
15.12.2015 / 12:07
1

Try this:

$('.modal-body label').text(descricao)
    
15.12.2015 / 18:00