So I am trying to apply JavaScript to an entire column in an Html table.
Below is my Script (please ignore the first daterange function but I wanted to show the full code):
All I am trying to do is add a breakline after each comma in the Message row of the table. Any idea where I am going wrong? Thank you.
<script type="text/javascript">
$(function() {
$('input[name="daterange"]').daterangepicker({
singleDatePicker: true,
locale: {
format: 'YYYY-MM-DD'
}
});
function formatMessage() {
var yourString = document.getElementById('msg').value;
var formattedText = yourString.split(",").join("\n");
$('msg').html(formattedText);
};
});
</script>
Below is the relevant HTML:
<table class="table table-striped jambo_table bulk_action">
<thead>
<tr class="headings">
<th class="column-title">Message</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="statement in statements track by $index">
<td class=" " id="msg" style="display:none;">{{statement.msg}}</td>
<td class=" ">{{statement.msg}}</td>
</tr>
</tbody>
</table>