I have the function below:
var players = function(){ var $div = $('<div>').attr('id', 'prompt'); var $input = $('<input>').attr('class', 'player' + playerNames); var $p = $('<p>').attr('class', 'player' + playerNames).html("Enter First Player" ); $div.append($input).append($p); $('.container').append($div); $('input').keydown(function(e) { if(e.keyCode === 13) { $div.addClass('move-left').removeAttr('id'); playerOne = $input.val(); $p.html($input.val()) $input.remove(); } }); } I want to call this function twice in a row.
I want the .addClass('move-left') to be addClass('move-right') playerNames which starts at 0 to be 1 and finally for the "Enter First Player" to be "Enter Second Player".
Do I need a for? if so does it have to wrap the entire function?
Thanks!
hasClass()to check if.addClass('move-left')has occurred and if it has thenaddClass('move-right')-- okay after your edit im not sure what your after in the rest of your question