JSFiddle - React, Tailwind, and code Playground
by farid silva aboid
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>
<div class="container">
<ul class="list-inline">
<li>
<button id="botEn" class="btn bnt-default">ENGLISH</button>
</li>
<li>
<button id="botEs" class="btn bnt-default">ESPAÑOL</button>
</li>
</ul>
</div>
<div class="alert alert-info">
</div>
JavaScript
jQuery(document).ready(function($) {
$('#botEn').click(function(e) {
Cookies.set('idioma', 'en', {
expires: 7,
path: '/'
});
$('.alert').html('<p>Btn english >> cookie:'+Cookies.get('idioma')+'</p>');
});
$('#botEs').click(function(e) {
Cookies.set('idioma', 'es', {
expires: 7,
path: '/'
});
$('.alert').html('<p>Btn español >> cookie:'+Cookies.get('idioma')+'</p>');
});
});
/*!
* JavaScript Cookie v2.1.3
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;
(function(factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function() {
window.Cookies = OldCookies;
return api;
};
}
}(function() {
function extend() {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[i];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init(converter) {
function api(key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
...