如何更改onload创建的元素的文本

时间:2016-04-25 14:34:47

标签: jquery twitter-bootstrap dom

我使用了一个插件,它在页面加载时创建按钮,我想在插件创建后在页面加载时更改文本,那么我怎样才能使用jquery呢?

我使用bootstrap数据表,我想更改标签和按钮文本,如下一个和上一个,我想更改标签,如显示标签

在我的代码中,这行代码Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Open(fileName) objWord.Visible = False ' Do heavy work here. ' Do heavy work here. objDoc.SaveAs(file.ParentFolder & "/" & theBaseName & " _compiled") 创建了带有按钮的数据表,以便我可以在特定按钮的情况下更改文本。

Html代码

$('#results').DataTable();

js代码

<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>

3 个答案:

答案 0 :(得分:1)

$(document).ready(function () {
$("#your-button-id").text("this is your new text");

// or try this

$("#your-button-id").html("this is your new text");
});

答案 1 :(得分:1)

Datatables文档说您可以通过编辑语言对象来编辑其界面中使用的所有字符串。Datatables documentation

如果我想将界面更改为法语,例如:

$(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"
      }
    }
  });
});

答案 2 :(得分:0)

您可能必须使用one of the datatable's events在适当的时候进行必要的更改。