Created
March 20, 2015 14:27
-
-
Save brunopulis/dc35e481af05679417eb to your computer and use it in GitHub Desktop.
Dinamic List with Js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var main = function(){ | |
var btn = $('.btn'); | |
btn.on('click', function(){ | |
var post = $('.status-box'); | |
post.val(); | |
$('<li>').text(post).prependTo('.posts'); | |
$('.status-box').val(''); | |
$('.counter').text('140'); | |
$('.btn').addClass('disabled'); | |
}); | |
$('.status-box').keyup(function(){ | |
var postLength = $(this).val().length, | |
charactersLeft = 140 - postLength; | |
$('.counter').text(charactersLeft); | |
if( charactersLeft < 0 ) { | |
$('.btn').addClass('disabled'); | |
} | |
else if( charactersLeft == 140) { | |
$('.btn').addClass('disabled'); | |
} | |
else { | |
$('.btn').removeClass('disabled'); | |
} | |
}); | |
$('.btn').addClass('disabled'); | |
}; | |
$(document).ready(main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment