-2

I have a simple table generated from Django template variable:

{% for object in object_list %}
    <tr>
        <td class="c9">{{object.first_name}}</td>
        <td class="c9">{{object.last_name}}</td>
        <td class="c9">{{object.tel}}</td>
    </tr>
{% endfor %}

I'm making insert to this model and the server side is done, but how to add a new row in top of this table? With this method: var row = table.insertRow(0)? or can I change this variable 'object_list' and row will be added automatically?

This simple solution 'var row = table.insertRow(0);' is not adding columns with CSS classes.

1
  • 1
    You can add the css classes manually. But I don't see much reason to add it to every td, why not put it in the table <table class="c9"> and apply the selector as td.c9 tr td { ...} instead of td.c9 { ... }. Commented Aug 9 at 11:16

1 Answer 1

0

This simple solution var row = table.insertRow(0); is not adding columns with CSS classes.

You probably don't have to add the css class in the first place.

Instead you could use:

<table class="c9">
    <!-- … -->
</table>

and then in the css selector use:

table.c9 tr td {
    /* … */
}

instead of:

td.c9 {
    /*  … */
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.