Our student information system is now using a format allowing us to inject code into html pages without actually editing the pages. The pages have what are called "custom insertion points" which I've been successful in getting to work to modify the menu pretty easily.
I'm now attempting to prepend a table row on an unnamed table after the tbody element. I know this page has only one table and one tbody. I've read and tried any number of formats to achieve this, but I've not had any luck to date.
Below is the code I thought should have worked pretty well, but though I can see the code in the source of the page (thanks to the custom insertion div), it's not properly traversing the DOM and inserting the row.
Could somebody please tell me how to correct my code? I've no idea what I'm doing incorrectly.
Thanks Schelly
<script>
$(document).ready(function(){
$("table > tbody").prepend("<tr bgcolor="#BAD3E5"><td class="bold">Campus ID</td> <td><input type="text" name="[01]CampusID" id="campusid" value=""></td></tr>");
});
</script>
I think just messed up the quotes. The opening quote for an HTML attribute closes the the opening quote of the prepend function. Try using different types of quotes:
<script>
$(document).ready(function(){
$("table > tbody").prepend('<tr bgcolor="#BAD3E5"><td class="bold">Campus ID</td> <td><input type="text" name="[01]CampusID" id="campusid" value=""></td></tr>');
});
</script>