Haidar Haidar - 7 months ago 10
Javascript Question

how to change the text of element created onload

I used a plugin which creates buttons on page load and I want to change their texts on page load after that plugin creates them, so how can I do that using jquery?

I use bootstrap data table and I want to change the labels and the buttons texts like next and previous and I want to change labels like the show label

in my code this line of code

$('#results').DataTable();
creates the data table with its buttons so how cab I change the text if specific button.

Html Code

<table id="results" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<td>إسم الموظف</td>
<td>رقم الموظف</td>
<td>الإدارة</td>
<td>مدير الجهة</td>
<td>مدير الإدارة</td>
<td>نوع الإجازة</td>
<td>تاريح بدء الإجازة</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>




js code

$(document).ready(function () {
$('#results').DataTable();
});

Answer

The Datatables documentation says you can edit all strings used in it's interface by editing the language object.Datatables documentation

If i want to change interface to french for example :

$(document).ready(function() {
  $('#results').DataTable( {
    "language": {
      "lengthMenu": "Afficher _MENU_ lignes par page",
      "zeroRecords": "Rien trouvé - désolé",
      "info": "Page _PAGE_ sur _PAGES_",
      "infoEmpty": "Pas de données",
      "infoFiltered": "(sur _MAX_ enregistrements au total)",
      "paginate": {
        "first":      "Début",
        "last":       "Fin",
        "next":       "Suivant",
        "previous":   "Précédent"
      }
    }
  });
});
Comments