$('#tabs2').tabulous({
effect: 'slideLeft'
});
$('#text1in').keyup(function () {
var value = $(this).val();
$('#test1out').text(value);
}).keyup();
$('#text2in').keyup(function () {
var value = $(this).val();
$('#test2out').text(value);
}).keyup();
这是新的小提琴:New fiddle
它没有显示标签的工作情况。我可以让这个工作不在jsfiddle。但希望你会看到我想要做的事情。我有两个标签脚本工作和显示字段脚本工作。我似乎无法将它们组合在一起。只要我将表单字段添加到tabs-1 div容器中,它就不起作用。但是,它在tabs-1 div之外工作。
任何帮助将不胜感激。
谢谢!
答案 0 :(得分:1)
需要解决多个html,css和javascript问题。我必须在插件注册后移动$()。tabulous()初始化,修复你的html表格,修复导致你将文本框值推入文本框后面的div的CSS样式问题。 / p>
以下是HTML结构应该是什么样子的示例。 http://www.noupe.com/development/tabulous-js-organize-random-content-in-tabs-with-jquery.html
HTML(完整):
<div id="tabs">
<ul>
<li><a href="#tabs-1" title="">Back</a></li>
<li><a href="#tabs-2" title="">Back</a></li>
<li><a href="#tabs-3" title="">Back</a></li>
<li><a href="#tabs-4" title="">Back</a></li>
<li><a href="#tabs-5" title="">Back</a></li>
<li><a href="#tabs-6" title="">Back</a></li>
</ul>
<div id="tabs_container">
<div id="tabs-1">
<input id="text1in" type="text" value="some text" />
<span id="test1out" class="tabulousclear"></span>
<input id="text2in" type="text" value="some text" />
<span id="test2out" class="tabulousclear"></span>
</div>
<div id="tabs-2">
<p>2 - Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc.</p>
</div>
<div id="tabs-3">
<p>3 - Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc.</p>
</div>
<div id="tabs-4">
<p>4 - Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc.</p>
</div>
<div id="tabs-5">
<p>4 - Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc.</p>
</div>
<div id="tabs-6">
<p>4 - Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc.</p>
</div>
</div><!--End tabs container-->
</div><!--End tabs-->
CSS已添加:
#tabs_container div
{
position: relative !important;
}
Javascript(Full):
$('#text1in').keyup(function () {
var value = $(this).val();
$('#test1out').text(value);
}).keyup();
$('#text2in').keyup(function () {
var value = $(this).val();
$('#test2out').text(value);
}).keyup();
/*!
* strength.js
* Original author: @aaronlumsden
* Further changes, comments: @aaronlumsden
* Licensed under the MIT license
*/
;(function ( $, window, document, undefined ) {
var pluginName = "tabulous",
defaults = {
effect: 'scale'
};
// $('<style>body { background-color: red; color: white; }</style>').appendTo('head');
function Plugin( element, options ) {
this.element = element;
this.$elem = $(this.element);
this.options = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function() {
var links = this.$elem.find('a');
var firstchild = this.$elem.find('li:first-child').find('a');
var lastchild = this.$elem.find('li:last-child').after('<span class="tabulousclear"></span>');
if (this.options.effect == 'scale') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hidescale');
} else if (this.options.effect == 'slideLeft') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hideleft');
} else if (this.options.effect == 'scaleUp') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hidescaleup');
} else if (this.options.effect == 'flip') {
tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hideflip');
}
var firstdiv = this.$elem.find('#tabs_container');
var firstdivheight = firstdiv.find('div:first').height();
var alldivs = this.$elem.find('div:first').find('div');
alldivs.css({'position': 'absolute','top':'0px'});
firstdiv.css('height',firstdivheight+'px');
firstchild.addClass('tabulous_active');
links.bind('click', {myOptions: this.options}, function(e) {
e.preventDefault();
var $options = e.data.myOptions;
var effect = $options.effect;
var mythis = $(this);
var thisform = mythis.parent().parent().parent();
var thislink = mythis.attr('href');
firstdiv.addClass('transition');
links.removeClass('tabulous_active');
mythis.addClass('tabulous_active');
thisdivwidth = thisform.find('div'+thislink).height();
if (effect == 'scale') {
alldivs.removeClass('showscale').addClass('make_transist').addClass('hidescale');
thisform.find('div'+thislink).addClass('make_transist').addClass('showscale');
} else if (effect == 'slideLeft') {
alldivs.removeClass('showleft').addClass('make_transist').addClass('hideleft');
thisform.find('div'+thislink).addClass('make_transist').addClass('showleft');
} else if (effect == 'scaleUp') {
alldivs.removeClass('showscaleup').addClass('make_transist').addClass('hidescaleup');
thisform.find('div'+thislink).addClass('make_transist').addClass('showscaleup');
} else if (effect == 'flip') {
alldivs.removeClass('showflip').addClass('make_transist').addClass('hideflip');
thisform.find('div'+thislink).addClass('make_transist').addClass('showflip');
}
firstdiv.css('height',thisdivwidth+'px');
});
},
yourOtherFunction: function(el, options) {
// some logic
}
};
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function ( options ) {
return this.each(function () {
new Plugin( this, options );
});
};
})( jQuery, window, document );
$('#tabs').tabulous({
effect: 'slideLeft'
});
答案 1 :(得分:-2)
在您的小提琴中缺少明确的插件,如果您从代码中删除以下行,它可以正常工作或正确安装tabbly插件。
$('#tabs2').tabulous({
effect: 'slideLeft'
});
希望这会对你有所帮助。