Answer the question
In order to leave comments, you need to log in
Can you please explain why this code does not work?
Imagine that there is an html table in the admin panel with columns: username, something else and the "Ban" button. When you click on the button, an ajax request is sent and, in theory, the text of the button changes to "Unban". This is exactly what I can not achieve (Ie, the inscription on the button does not change). Please explain what I'm doing wrong.
Utils.bahn = function( index ) {<br>
// table bahn_list select<br>
var row = $('#bahn_list tr').eq( index + 1 )[0];<br>
var name = row.cells[0].innerHTML;<br>
<br>
var input = $( row.cells[3].innerHTML );<br>
<br>
if( input.val() == "Зобанить" ) {<br>
Utils.sendPackage( Utils.createBahnPackage(name) );<br>
input.val( "Розбанить" );<br>
input.attr('value', 'Розбанить');<br>
}<br>
else if( input.val() == "Розбанить" ) {<br>
Utils.sendPackage( Utils.createUnBahnPackage(name) );<br>
input.val( "Зобанить" );<br>
}<br>
}<br>
Answer the question
In order to leave comments, you need to log in
Doesn't work because
var input = $( row.cells[3].innerHTML );
<input type="button">
lies), but will create a new one, to which it will change its value.
In my opinion, since you are already using jquery, you do not need to interfere with it with native code.
your piece
var row = $('#bahn_list tr').eq( index + 1 )[0];
var name = row.cells[0].innerHTML;
var input = $( row.cells[3].innerHTML );
var row = $('#bahn_list tr').eq(index + 1);
var name = $('td:first', row).html();
var input = $('td:eq(3) > input', row);
input.val( "Розбанить" );
input.attr('value', 'Розбанить');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question