首页 > Web开发 > 详细

Content Editor Webpart(二)添加JQuery和html代码

时间:2015-03-19 13:22:42      阅读:319      评论:0      收藏:0      [点我收藏+]

在上一篇(Content Editor Webpart(一)引用JQuery  )中介绍了如何在Content Editor Webpart中引用JQuery, 这一篇介绍一下如果在Content Editor Webpart中添加html和JQuery代码。


按照上一篇的步骤,编辑Content Editor Webpart的源代码,输入如下代码:

<div style="height: 200px;">
<script type="text/javascript" src="/sites/apps/Style%20Library/jquery-1.10.2.min.js"></script>
<script> 
$(document).ready(function(){
    $("#btnStr").click(function(){
        $("#move").animate({left: '250px'});
    });
});
</script>

<button id="btnStr" onclick="moveDiv()">Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. 
      <br/>To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div id="move" style="height: 100px; width: 100px; position: absolute; background: #98bf21;"></div> 
</div>

技术分享

保存完之后,显示成这样:

技术分享


点击Start Animation,绿色的div块就会移动起来:

技术分享 


点击

Content Editor Webpart(二)添加JQuery和html代码

原文:http://blog.csdn.net/spfarm/article/details/44454465

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!