Monday, 19 August 2013

Add text to input

Add text to input

I would like that jquery adds the value of a class="num" to the form with
the id="form2" when the class="text" is clicked. Its important that only
the value of the next "num"-class after the "text"-class is added to the
form!
<p class="text" >
<a class="num"><%= g.nummer %></a><a class="bez"><%= g.bezeichnung %></a>
</p>
<input id="form2" name="suche" type="text">
My actual code:
$(document).on("click", ".text", function() {
$("#Content").html($(this).next(".text1").html());
$("#form2").html($(this).next(".num").val());
$('.text').css('color','');
$(this).css( "color", "red" );
});
});
But somehow this line wont work:
$("#form2").html($(this).next(".num").val());
Thanks!

No comments:

Post a Comment