Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need help accessing a button inside a div [duplicate]

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

I'm iteration over 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 this doesn't 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 stuff".

Any help would be greatly appreciated.

like image 295
Simmer Avatar asked Oct 20 '16 10:10

Simmer


2 Answers

Try this:

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

Remove space in find method

like image 145
Atul Mishra Avatar answered Nov 03 '22 01:11

Atul Mishra


   for(var i = 0, cell; cell = table.cells[i]; i++) {                            
        $(cell).find('.btn .btn-default').val("new value");                  
    }
like image 1
user2362008 Avatar answered Nov 02 '22 23:11

user2362008