【问题标题】:text not showing within javascript functionjavascript函数中未显示文本
【发布时间】:2016-05-22 00:34:54
【问题描述】:

这是我的 jquery

$(document).ready(function() {
        $('.test').text('Hello');
})

除了我的javascript函数..

 function format ( d ) {
        // `d` is the original data object for the row
        return '<div class="slider">'+
            '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
            '<tr>'+
            '<td>Full name:</td>'+
            '<td>'+d.name+'</td>'+
            '</tr>'+
            '<tr>'+
            '<td>Extension number:</td>'+
            '<td>'+d.extn+'</td>'+
            '</tr>'+
            '<tr>'+
            '<td colspan="2"><div class="test"></div></td>'+
            '</tr>'+
            '</table>'+
            '</div>';
    }

当我在格式函数中调用测试类时,“你好”文本没有显示,但我写了纯文本,比如......然后显示了。

任何人都可以帮助我......

##重要## 格式化函数使用其他地方

【问题讨论】:

  • 你需要将该 html 插入 DOM 以进行操作。

标签: javascript jquery datatable


【解决方案1】:

当“.test”处于功能状态时,您无法使用$('.test').text('Hello'); this 更改文本。 您可以在添加文本时添加延迟,例如

$(document).ready(function() {
    $('.test').delay(1000).text('Hello');
})

【讨论】:

    猜你喜欢
    • 2022-06-23
    • 2013-11-07
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多