I need help accessing a button inside a div

I am trying to update the value attribute of a button inside a table cell.

I iterate through each cell, and my code looks like this:

for (var i = 0, cell; cell = table.cells[i]; i++) { $(cell).find('.btn btn-default').val("new value"); } 

But that does not work.

My cell looks like this:

 <div class=\"list-element\"> <a class=\"glyphicon glyphicon-link\" href=\"www.somelink\"></a> <input class=\"btn btn-default\" type=\"button\" value=\"some stuff\"> <label class=\"label label-success\">stuff</label> </div> 

So, I want to change "some things."

Any help would be greatly appreciated.

+5
source share
2 answers

Try the following:

  for (var i = 0, cell; cell = table.cells[i]; i++) { $(cell).find('.btn.btn-default').val("new value"); } 

Delete location in search method

+2
source
  for(var i = 0, cell; cell = table.cells[i]; i++) { $(cell).find('.btn .btn-default').val("new value"); } 
+1
source

Source: https://habr.com/ru/post/1258521/


All Articles