LaVOZs

The World’s Largest Online Community for Developers

'; javascript - Insert new row at the first position of a table dynamically with js? - LavOzs.Com

function renderCafe (doc) {
    //let tale1 = document.getElementById("cafe-list");
    let li = document.createElement('tr');
    let name = document.createElement('td');
    let city = document.createElement('td');

    let status = document.createElement('td');
    let cross = document.createElement('td')

    li.setAttribute('data-id', doc.id);
    name.textContent = doc.data().name;
    city.textContent = doc.data().device;
    status.textContent = doc.data().status;
    cross.textContent = "x";

    li.appendChild(cross);
    li.appendChild(status);
    li.appendChild(city);
    li.appendChild(name);
    cafeList.appendChild(li);}

I use firebase data to fill the table and I want to make when the user make new item its will show at the first row table and not the last didn't quite get how to do so with js tx alot

edit: the user submit 2 parameters and then i have listener event that detect new item in the database and then this function called and i want to pass 4 values (that i get from the object i passed from my database to new row in my table something like that:

Name: Device: Status: Remove:
A      B       C       X
OLD    OLD     OLD     X
Related
Add table row in jQuery
Space between two rows in a table?
What is JSONP, and why was it created?
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
JQuery - Row click event won't fire on newly added table rows
Edit and Delete firebase
How do I insert a new form table row with JavaScript and get it included in what's passed to the controller?
insert multiple data into mysql table in single form with codeigniter