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

在上一篇(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" οnclick="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块就会移动起来:

 


点击

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值