php – How do I set value to input type text with dynamic id, using jQuery?-ThrowExceptions

Exception or error:

I have div element with dynamic id for input type text.

this is my html code.

<?php 
for($j=0;$j<=3;$j++){
?>
 <input type="text" id="money<?php echo $j; ?>"/>
<?php
}
?>

And this is my script. I try with this code but its not work, and the value is still empty.

$("#money1").val("200");

I try with this code and its working, but it affect all of the input type text with ‘money’ id.

$('input[id^="money"]').val("200");

please help me, I’m already stuck.

Thank you for your attention.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *