Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Append content on random location with jQuery?
- <ul class="itemlist">
- <li>Item #2</li>
- <li>Item #2</li>
- <li>Item #3</li>
- <li>Item #4</li>
- </ul>
- .itemlist li{
- width:100px;
- height: 100px;
- margin: 8px;
- padding: 4px;
- float: left;
- background: #dddddd;
- }
- var $lis = $(".itemlist li");
- $lis.eq(Math.floor(Math.random()*$lis.length)).after(
- /* your new content here */ );
- var randomNum = Math.floor(Math.random()*9);
- $(".itemlist li").eq(randomNum).append("HI");
Add Comment
Please, Sign In to add comment