/* Latest compiled and minified CSS included as External Resource*/
body {
margin: 10px;
}
.tab-pane {
padding:5px;
}
.ibutton-close {
margin-left:10px;
cursor:pointer;
}
.tab-content {
min-height:150px;
height:100%;
border-left:solid 1px #a1d470;
border-bottom:solid 1px #a1d470;
border-right:solid 1px #a1d470;
}
/* Estilo del tab activo*/
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
border-bottom-color:transparent !important;
height:40px;
color:#777;
margin-top:0px;
line-height:10px!important;
font-size:16pt;
}
/* Estilos de los tabs inactivos*/
.nav-tabs > li > a, .nav-tabs > li > a:hover, .nav-tabs > li > a:focus {
color:#fff;
border-color:#a1d470 !important;
background-color:#a1d470;
height:30px;
margin-top:10px;
line-height:15px !important;
}
.button {
border: 2px solid #a1d470 !important;
width:105px;
height:40px;
padding:7px;
line-height:20px;
border-radius: 10px;
margin:10px 0px 30px 0px;
cursor:pointer;
}
.textBox {
margin:15px 0px 0px 15px;
width:200px;
height:30px;
}
JavaScript
// Función para añadir un nuevo tab
function añadirTab() {
var textoTab = $('#nombreTab').val();
var contenidoTab = $('#contenidoTab').val();
if (textoTab == '') {
alert('El nombre del Tab debe estar informado');
} else {
// Tenemos nombre para el tab
AñadirNuevoTab(textoTab, contenidoTab);
}
}
/******************************************************
* FUNCIÓN QUE AÑADE UN NUEVO TAB A LA LISTA DE TABS*
******************************************************/
function AñadirNuevoTab(textoTab, contenido) {
var nuevoIdTab = ObtenerNuevoIdTab();
// Generamos el código del nuevo Tab
var nuevoTab = "<li class='tabCntrl' id='tab" + nuevoIdTab + "'>";
nuevoTab = nuevoTab + "<a href='#informe" + nuevoIdTab;
nuevoTab = nuevoTab + "' data-toggle='tab'>" + textoTab;
nuevoTab = nuevoTab + "<i id='" + nuevoIdTab + "' class='fa fa-times ";
nuevoTab = nuevoTab + "ibutton-close' onclick='closeTab(this);'>"
nuevoTab = nuevoTab + "</i></a></li>";
// Lo concatenamos en la lista de tabs
$('#myTab').append(nuevoTab);
// Generamos el código del contenido del nuevo tab
var nuevoContenidoTab = "<div class='tab-pane' id='informe" + nuevoIdTab + "'>";
nuevoContenidoTab = nuevoContenidoTab + "<p>" + contenido + "</p></div>";
// Concatenamos el contenido en el div de contenidos
$('.tab-content').append(nuevoContenidoTab);
// Le quitamos la clase activa al que esté activo en este momento:
$(".tabCntrl").each(function (index) {
$(this).removeClass('active');
});
$('.tab-pane').each(function (index) {
$(this).removeClass('active');
});
// Activamos el nuevo tab
$('#tab' + nuevoIdTab).addClass('active');
$('#informe' + nuevoIdTab).addClass('active');
}
/******************************************************
* FUNCIÓN QUE OBTIENE UN NUEVO ID DE TAB *
******************************************************/
function...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.