Javascript jquery单击禁用该函数 $('document').ready(函数(){ //textoverflow($('.content'),100); $('span')。单击(函数(){ //禁用textoverflow功能并输出全文 }); }); 函数textoverflow(ele,num){ 元素每个(函数(){ $(此).text( $(this).text().slice(0,num)+'…' ).append('More'); }); }
我有一个文本使用函数切片的内容 用户单击时有一个按钮,我只想禁用Javascript jquery单击禁用该函数 $('document').ready(函数(){ //textoverflow($('.content'),100); $('span')。单击(函数(){ //禁用textoverflow功能并输出全文 }); }); 函数textoverflow(ele,num){ 元素每个(函数(){ $(此).text( $(this).text().slice(0,num)+'…' ).append('More'); }); },javascript,jquery,Javascript,Jquery,我有一个文本使用函数切片的内容 用户单击时有一个按钮,我只想禁用$this.content&output所有不带切片的文本的功能 如何禁用该功能?您需要保留原始文件的副本,以便以后恢复。例如: $('document').ready(function(){ //textoverflow($('.content'),100); $('span').click(function(){ //disable textoverflow function & out
$this.content
&output
所有不带切片的文本的功能
如何禁用该功能?您需要保留原始文件的副本,以便以后恢复。例如:
$('document').ready(function(){
//textoverflow($('.content'),100);
$('span').click(function(){
//disable textoverflow function & output full text
});
});
function textoverflow(ele, num){
ele.each(function() {
$(this).text(
$(this).text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
函数截断(ele,num){
元素每个(函数(){
var self=$(this);//缓存这个,因为我们在3个地方使用它
//在截断之前保留原始文本的副本
self.data('original',self.text()).text(
self.text().slice(0,num)+'…'
).append('More');
});
}
功能显示完整(ele){
元素每个(函数(){
var self=$(这是);
//恢复Original并删除More链接
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(函数(){
截断($('.content'),100);
$('span')。单击(函数(){
showFull($(this).closest('.content'));
});
});
您需要保留原件的副本,以便以后能够还原。例如:
$('document').ready(function(){
//textoverflow($('.content'),100);
$('span').click(function(){
//disable textoverflow function & output full text
});
});
function textoverflow(ele, num){
ele.each(function() {
$(this).text(
$(this).text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
函数截断(ele,num){
元素每个(函数(){
var self=$(this);//缓存这个,因为我们在3个地方使用它
//在截断之前保留原始文本的副本
self.data('original',self.text()).text(
self.text().slice(0,num)+'…'
).append('More');
});
}
功能显示完整(ele){
元素每个(函数(){
var self=$(这是);
//恢复Original并删除More链接
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(函数(){
截断($('.content'),100);
$('span')。单击(函数(){
showFull($(this).closest('.content'));
});
});
您需要保留原件的副本,以便以后能够还原。例如:
$('document').ready(function(){
//textoverflow($('.content'),100);
$('span').click(function(){
//disable textoverflow function & output full text
});
});
function textoverflow(ele, num){
ele.each(function() {
$(this).text(
$(this).text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
函数截断(ele,num){
元素每个(函数(){
var self=$(this);//缓存这个,因为我们在3个地方使用它
//在截断之前保留原始文本的副本
self.data('original',self.text()).text(
self.text().slice(0,num)+'…'
).append('More');
});
}
功能显示完整(ele){
元素每个(函数(){
var self=$(这是);
//恢复Original并删除More链接
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(函数(){
截断($('.content'),100);
$('span')。单击(函数(){
showFull($(this).closest('.content'));
});
});
您需要保留原件的副本,以便以后能够还原。例如:
$('document').ready(function(){
//textoverflow($('.content'),100);
$('span').click(function(){
//disable textoverflow function & output full text
});
});
function textoverflow(ele, num){
ele.each(function() {
$(this).text(
$(this).text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
函数截断(ele,num){
元素每个(函数(){
var self=$(this);//缓存这个,因为我们在3个地方使用它
//在截断之前保留原始文本的副本
self.data('original',self.text()).text(
self.text().slice(0,num)+'…'
).append('More');
});
}
功能显示完整(ele){
元素每个(函数(){
var self=$(这是);
//恢复Original并删除More链接
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(函数(){
截断($('.content'),100);
$('span')。单击(函数(){
showFull($(this).closest('.content'));
});
});
复制原始文本并将其存储在数据属性中。循环并将文本放回原处
function truncate(ele, num){
ele.each(function() {
var self = $(this); // cache this, since we are using it in 3 places
// keep a copy of the original text, before truncating
self.data('original', self.text()).text(
self.text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
function showFull(ele){
ele.each(function() {
var self = $(this);
// restore orignial and remove the More link
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(function(){
truncate($('.content'),100);
$('span').click(function(){
showFull($(this).closest('.content'));
});
});
函数textoverflow(ele,num){
元素每个(函数(){
var项目=$(此项);
var orgText=item.text();
如果(orgText.length>num){
项目数据(“orgtext”,orgtext);
text(item.text().slice(0,num)+'…');
项目。附加(“更多”);
}
});
}
函数undoTextoverflow(ele){
元素每个(函数(){
var项目=$(此项);
var orgText=项目数据(“orgText”);
如果(orgText){
项目.文本(orgText);
}
});
}
$(函数(){
textoverflow($('.content'),100);
$('.content')。在(“单击”,“跨距”,函数()上){
var parentElem=$(this).closest(“.content”);
undoTextoverflow(parentElem);
});
});
复制原始文本并将其存储在数据属性中。循环并将文本放回原处
function truncate(ele, num){
ele.each(function() {
var self = $(this); // cache this, since we are using it in 3 places
// keep a copy of the original text, before truncating
self.data('original', self.text()).text(
self.text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
function showFull(ele){
ele.each(function() {
var self = $(this);
// restore orignial and remove the More link
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(function(){
truncate($('.content'),100);
$('span').click(function(){
showFull($(this).closest('.content'));
});
});
函数textoverflow(ele,num){
元素每个(函数(){
var项目=$(此项);
var orgText=item.text();
如果(orgText.length>num){
项目数据(“orgtext”,orgtext);
text(item.text().slice(0,num)+'…');
项目。附加(“更多”);
}
});
}
函数undoTextoverflow(ele){
元素每个(函数(){
var项目=$(此项);
var orgText=项目数据(“orgText”);
如果(orgText){
项目.文本(orgText);
}
});
}
$(函数(){
textoverflow($('.content'),100);
$('.content')。在(“单击”,“跨距”,函数()上){
var parentElem=$(this).closest(“.content”);
undoTextoverflow(parentElem);
});
});
复制原始文本并将其存储在数据属性中。循环并将文本放回原处
function truncate(ele, num){
ele.each(function() {
var self = $(this); // cache this, since we are using it in 3 places
// keep a copy of the original text, before truncating
self.data('original', self.text()).text(
self.text().slice(0,num) + '...'
).append('<span>More</span>');
});
}
function showFull(ele){
ele.each(function() {
var self = $(this);
// restore orignial and remove the More link
self.text(self.data('original').find('span').remove();
});
}
$('document').ready(function(){
truncate($('.content'),100);
$('span').click(function(){
showFull($(this).closest('.content'));
});
});
函数textoverflow(ele,num){
元素每个(函数(){
var项目=$(此项);
var orgText=item.text();
如果(orgText.length>num){
项目数据(“orgtext”,orgtext);
text(item.text().slice(0,num)+'…');
项目。附加(“更多”);
}
});
}
函数undoTextoverflow(ele){
元素每个(函数(){
var项目=$(此项);
var orgTex