I have a html table and I want to append a form to each tr. I have written this:
<script>
var bform = '<form name="input" action="html_form_action.asp" method="get"><input type="hidden" value="event"></input><input type="submit" value="Submit" /></from>';
$('tr').prepend(bform);
</script>
But it does not seem to be working for me, nor is it throwing an error in the console.
Could some one point me in the right direction?
Add
trandtdto yourbformWhen you prepend a string to a
tr, you are inserting inside atable, so, your current code is invalid:As Blender said, make sure you put the code inside a
jQuery(document).ready(function($){})Additionally, you don’t need to close
inputs, so, both are valid codes: