动态添加内容到滚动区域

 

<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/html">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>

<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.bootstrap.newsbox.min.js" type="text/javascript"></script>

<style>
li {
list-style-type: none
}
</style>
</head>

<body>

<!--新闻滚动-->
<div class="container ">
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">
<span class="glyphicon glyphicon-list-alt"></span><b>大家来吐槽</b></div>
<div class="panel-body">
<div class="row">
<ul class="demo1" id="new">
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/1.png" width="60" class="img-circle"/></td>
<td>又一天过去了。今天过得怎么样,梦想是不是更远了?</td>
</tr>
</table>
<hr>
</li>

<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/2.png" width="60" class="img-circle"/></td>
<td>是金子早晚也会花光 但如果你是石头 到哪里都不会发光的</td>
</tr>
</table>
<hr>
</li>
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/3.png" width="60" class="img-circle"/></td>
<td>长得丑就是病,不然整形医院为什么会是医院。</td>
</tr>
</table>
<hr>
</li>
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/4.png" width="60" class="img-circle"/></td>
<td>假如今天生活欺骗了你,不要悲伤,不要心急,因为明天生活还会继续欺骗你
多被骗几次你就习惯了
</td>
</tr>
</table>
<hr>
</li>
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/5.png" width="60" class="img-circle"/></td>
<td>如果你觉得自己,整天累得跟狗一样。

  你真是误会大了,狗都没有你这么累。
</td>
</tr>
</table>
<hr>
</li>
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/6.png" width="60" class="img-circle"/></td>
<td>长相是上一代给的,教育是上一代定的,

  观念是上一代教的,环境是上一代留的,

  居然还好意思说:一代不如一代。
</td>
</tr>
</table>
<hr>
</li>
<li class="news-item">
<table cellpadding="4">
<tr>
<td><img src="img/7.png" width="60" class="img-circle"/></td>
<td>我相信只要努力工作就一定能取得成功。当年刚工作时我身无分文,但凭借着踏实工作和勤奋好学,我银行里不仅不再是零存款,还成功的欠了他们一大笔钱。</td>
</tr>
</table>
<hr>
</li>
</ul>
</div>
</div>
</div>
</div>

</div>
<script>
$(function () {
$(".demo1").bootstrapNews({
newsPerPage:4,
autoplay: true,
direction: 'up',
newsTickerInterval: 2000,
/* onToDo: function () {
}*/
});
});
</script>

<!--消息发布框-->


<div class="container-fluid navbar-fixed-bottom" style="background-color:#c9302c">
<div class="row">
<button type="button" class="btn btn-default btn-md col-xs-4 col-xs-offset-4" data-toggle="modal"
href="#myModal">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>

</div>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal" type="button">&times;</button>
<h4 class="modal-title">没事吐槽下吧</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<textarea id="txt" class="form-control" rows="3" placeholder="说点什么吧"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" id="btnClose" class="btn btn-default">关闭</button>
<button type="button" id="submit" class="btn btn-primary">发布</button>
</div>

</div>
</div>
</div>
<!--关闭窗体-->
<script>

$(function () {
$("#btnClose").click(
function () {
$("#myModal").modal("hide");
}
);

$ ("#submit").click (function ()
{ // 产生随机数
var num = Math.floor((Math.random()*10)+1);

// 获取文本信息
var text = $("#txt").val();
// 添加到新闻列表里面
$('#new').append('<li class="news-item"><table cellpadding="4"><tr> <td><img src="img/'+num+'.jpg" width="60" class="img-circle"/></td> <td>'+text+'</td> </tr> </table> <hr> </li>');
$("#myModal").modal("hide");
});

})
</script>


</body>

</html>
posted @ 2017-03-02 13:55  iriliguo  阅读(379)  评论(0编辑  收藏  举报