css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!--No cambiar las id de los tags html-->
<h4>Formulario de test</h4>
  <!--Contenedor del nombre cookie-->
  <input type="text" class="child-form" id="name_cookie_txt" placeholder="Nombre cookie">
  <!--Contenedor del valor cookie-->
  <input type="text" class="child-form" id="cookie_valor_txta" placeholder="Valor cookie">
   <!--Contenedor del valor numérico (días de vida de la cookie)-->
  <input type="text" class="child-form" id="num_dias_expirar_txt" placeholder="Número de días">
   <!--Botón para crear la cookie-->
  <button class="child-form btn" id="crear_cookie_btn">Crear cookie</button>
  <!--Contenedor del nombre de la cookie a leer-->
  <input type="text" class="child-form" id="leer_cookie_txt" placeholder="Ingrese el nombre de la cookie">
  <!--Botón para leer la cookie-->
  <button class="child-form btn" id="leer_cookie_btn">Leer cookies</button>
    <!--Contenedor del nombre de la cookie a eliminar-->
  <input type="text" class="child-form" id="eliminar_txt" placeholder="Nombre cookie a eliminar">
  <!--Botón para eliminar la cookie-->
  <button class="child-form btn" id="eliminar_cookie_btn">Eliminar cookies</button>
<textarea class="child-form message" placeholder="Mensajes" disabled></textarea>

<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
              /*No es tan importante*/
h4{margin:0 0 10px 0;}
  width: 15%;
  display: inline-block;
  border-radius: 3px;
  border:thin solid;
  padding: 3px 0;
  margin-top: 15px;
  width: 105px;
  color: green;
  display: block;
  height: 20px;
  margin-top: 15px;
  min-height: 50px;
  width: 300px;
              	'use strict';
 //función para crear las cookies
function crearCookie(cookie_nombre, cookie_valor, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cookie_nombre + "=" + cookie_valor + "; " + expires+ "; path=/";
 //función para leer las cookies
function leerCookie(cookie_nombre) {
    var name = cookie_nombre + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    return "";
 //función para eliminar las cookies
function eliminarCookie(cookie_nombre) {
   return document.cookie = cookie_nombre + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
//crear cookie cuando el usuario de clic en el botón Crear cookie
 $('#crear_cookie_btn').on('click', function(e){
  var nCookie = $('#name_cookie_txt').val();
  var cValor = $('#cookie_valor_txta').val();
  var nDias = $('#num_dias_expirar_txt').val();
  var reg = /^([0-9]\s*)*$/;
  if(nCookie == 0){
    $('.message').html('Ingrese el nombre de la cookie');
    return false;
   if(cValor == 0){
    $('.message').html('Ingrese el valor para cookie a crear');
     return false;
  if(reg.test(nDias) && nDias != ""){
   crearCookie(nCookie, cValor, nDias);
    var d = new Date();
    d.setTime(d.getTime() + (nDias*24*60*60*1000));
   $('.message').html("Nombre cookie: "+nCookie+"="+cValor+"; expires="+d);
    $('.message').html('Ingrese un valor númerico, equivale a los días de vida de la cookie.');
    return false;
  //leer cookie cuando el usuario de clic en el botón Leer cookie
  $('#leer_cookie_btn').on('click', function(e){
    var nameCookieText = $('#leer_cookie_txt').val();
    var cookie = leerCookie(nameCookieText);
    if(nameCookieText != ""){
      if(cookie != ""){
        $('.message').html("Cookie: "+nameCookieText+"="+cookie);
        $('.message').html("Cookie: Null");
      $('.message').text("Ingresa el nombre de la cookie");
  //eliminar cookie cuando el usuario de clic en el botón Eliminar cookie
  $('#eliminar_cookie_btn').on('click', function(e){
    var cEliminar = $('#eliminar_txt').val();
    var cLeer = leerCookie(cEliminar);
   if(cEliminar != ""){
      if(cLeer != ""){
        $('.message').html('Cookie eliminada : ' + cEliminar );
        $('.message').html('No existe cookie con ese nombre');
      $('.message').html('Ingrese nombre de la cookie a eliminar');
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................