I recently posted a similar question, but after some discussion, the question turned out to be quite a bit different than it was originally stated, so I thought it best to post this as a new question. I am trying to use an input field to show a total (I would consider using another element type, but I need to do the same thing in other places where an input field is actually required, so I may as well fix the problem now). The problem is that the HTML of the table containing these fields needs to be reloaded on occasion, i.e. in table creation, I use the Jquery $('#table1').html($('#table1').html() + <next_table_line>);
. This causes the input field to revert to the value displayed in its value
attribute, which doesn't change when I use the $('#input1').val(<some_value>);
setter or when I enter data manually. Does anyone know of a solution to my problem? I need to be able to add rows to the table without loosing my data, but I can't figure out how to do this.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
You're reloading your entire table with the line
$('#table1').html($('#table1').html() + <next_table_line>);
. You should be appending to your table instead. Take the following sample small table:Now, to add a new row, dont re-write the entire table HTML, just append!
Demo: http://jsfiddle.net/uB2Rq/1/