简体   繁体   中英

Edit cell in table with javascript

update

I have a table written in javascript, now I want to edit the table. I have the following code in Javascript: but how can I type text in the cell ?

enter code here editCell: function(cell){
    if(cell.editMode != true) {                     
        cell.editmode = true;
        cell.innerHTML = "<p></p>";
    }
},

the table:

enter code here<body>
Cijfergegevens {COLVAL}

may be this can help but it in jquery,

 $('td#id').html("value");

 result is 

 <td id="id">value</td>

in javascript might be

  document.getElementById('id').innerHTML = "value"; 

FYI.

You cannot just type text in a table cell. You need a textfield inside the cell with markup like this:

<input type="text" id="txt-input" />

JavaScript after the HTML of your table

<table><tr><td id='cell1'></td></tr></table>
...
...
<script type="text/javascript">
    document.getElementById('cell1').innerHTML = "write some text";
</script>
...
</body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM