I want to get the data in the textarea which is in nested table. I use the row Index to get the data in that row.
I tried this , but it is not work.
var note = document.getElementById($index).cells[3];
var y = document.getElementsByTagName("textarea").value;
Here is the table.
<tr ng-repeat="(key, x) in records" id="{{$index}}">
<td>{{key}}</td>
<td>{{x.title}}</td>
<td>{{x.year}}</textarea></td>
<td>
<textarea rows="2" cols="30">{{x.note}}</textarea>
<button type="button" ng-click="update($index)">Update</button>
</td>
<td><button type="button" ng-click="delete($index)">Delete</button></td>
</tr>
Note that you also have the ending of a previous textarea control here, which might cause a problem for getElementsByTagName:
<td>{{x.year}}</textarea></td>
var y = document.getElementsByTagName("textarea")[0].value; alert(y);
<tr> <td>17</td> <td>Title</td> <td>Year</td> <td> <textarea rows="2" cols="30">this is my note</textarea> <button type="button">Update</button> </td> <td><button type="button">Delete</button></td> </tr>
Maybe here is the error, you are closing a textarea:
<td>{{x.year}}</td>
After try with it:
var y = document.getElementsByTagName("textarea")[0].value;
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.