I have an unordered list that I'm hoping to add the effect that when something is appended to it, it appears in a random position on the screen every time. However, since it's text in the list, I can't have each random position overlap. The text that gets appended will have a fadeout timer of 5 seconds, so once the message has faded out, that space will become available.
Is this possible? If so here is the HTML I'm using:
<ul id="messagebox" >
</ul>
<div>
<input type="text" id="typetextbox" maxlength="120" autocomplete="off" />
<button type="submit" id="submit" onblur="submit"> </button>
</div>
Here's the Javascript/jquery:
$(document).ready(function(){
$('#typetextbox').keypress(function (e){
if(e.keyCode == 13 ) $('#submit').click();
});
$('#submit').click(function(){
var message = $('#typetextbox').val();
if (message.replace(/ /g, ''))
$('#messagebox').append(message + "<br/>");
$("#typetextbox").val("");
});
});
If not, what can I do to get that effect?
Thanks guys!
http://jsfiddle.net/4a7Tj/2/
In order to get the list item to show up on random places, the CSS for that should be made
position:absolute
then you set the left and top according to the random values generatedCSS
JavaScript
the gridpos is based on the window's height and width along with the declared height width of the list items.