Reputation: 408
<html>
<?php for($i=1;$i<5;$i++){?>
<input type="text" value="<?php echo $i; ?>" id="val".$i>
<?php } ?>
</html>
<script src="../jquery-3.1.1.js"></script>
<script>
$("input").keyup(function()
{
alert($("#val").val());
});
</script>
NOTE I will try to get text-box value when key-up event fire but always first text box value display how i will get text-box value which key-up event fire
Upvotes: 0
Views: 578
Reputation: 1942
Use this
$("input").keyup(function()
{
alert($(this).val());
})
By the way, the id
attribute must be unique within the HTML document, see http://www.w3schools.com/tags/att_global_id.asp
Upvotes: 2