I want add text of div to #inputString value (value="text").
From -> <div class="row">text</div> or <div class="row">anothertext</div> etc. Same class different text.
$(document).ready(function() {
$('.row').click(function() {
var value = $(this).attr('.text');
$('input#inputString').val(value);
});
});
Given the sparsity of detail, I can only suggest:
JS Fiddle demo.
Where
inputSelectoris whatever selector you’re using to select yourinputelement.Note that we use the
text()method to retrieve the text of the element, not a text attribute. Although in some browsers the node may have atextproperty (but it’s still not an attribute of the element).