怎样在jQuery.datatable中添加自定义控件

怎样在jQuery.datatable中添加自定义控件,第1张

官网有例子在API,addrow那个例子里

<button id="addRow">Add new row</button>

<table id="example" class="display" cellspacing="0" width="100%">

<thead>

<tr>

<th>Column 1</th>

<th>Column 2</th>

<th>Column 3</th>

<th>Column 4</th>

<th>Column 5</th>

</tr>

</thead>

<tfoot>

<tr>

<th>Column 1</th>

<th>Column 2</th>

<th>Column 3</th>

<th>Column 4</th>

<th>Column 5</th>

</tr>

</tfoot>

</table>

//引入其他js

<script type="text/javascript" language="javascript" class="init">

$(document).ready(function() {

var t = $('#example').DataTable()

var counter = 1

$('#addRow').on( 'click', function () {

t.row.add( [

counter +'.1',

'<input type="button" value="button"/>',

'<a href="xxx">超链接</a>',

counter +'.4',

counter +'.5'

] ).draw()

counter++

} )

// Automatically add a first row of data

$('#addRow').click()

} )

</script>

add里面的分号内容 随便你插入什么格式的东西只要标签对就可以。

jquery插件有两种,一种是$('.xxx').xxx()另一种是$.xxx()自定义jquery插件,我理解是插件的写法啦。如下面示例代码//crud是插件的名字,可以替换成别的//1>(function($,window,document,undefined){$.fn.crud=function(options){varopts=$.extend({},$.fn.crud.defaults,options)this.each(function(){//这里是这个插件实现方法主内容})}$.fn.crud.defaults={//插件的参数}}(jQuery,window,document))//调用方法$('.xxx').crud({})//2>(function($,window,document,undefined){$.fn.extend.crud=function(options){varopts=$.extend({},$.fn.extend.crud.defaults,options)this.each(function(){//这里是这个插件实现方法主内容})}$.fn.extend.crud.defaults={//插件的参数}}(jQuery,window,document))//调用方法$.crud({})

所有设置都不生效?试一下这样看看哪里出错了。

<script>

(function ($) {

$("#avi1").attr("Height", 450)

alert('1')

$("#avi1").attr("Width", 800)

alert('2')

var lj="../AVI.avi"

$("#avi1").attr("AviVideoFile", "<%=ResolveUrl(" + lj + ") %>")

alert('3')

})

</script>

看看有没有d出三个对话框?哪个没有d?还有,下面这句:

$("#avi1").attr("AviVideoFile", "<%=ResolveUrl(" + lj + ") %>")

换成:

$("#avi1").attr("AviVideoFile", "<%=ResolveUrl('+ lj + ') %>")

这个看看?行不行的话,也没准。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11871832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存