我正在学习如何在SharePoint中使用jquery.我的示例在选择链接时在内容编辑器Web部件中绘制一个红色框.我的代码在SharePoint页面处于编辑模式时工作,但在我离开页面并以非编辑模式返回后不能工作.jquery函数由于某种原因不会触发...我遗漏了一些简单但不确定的东西.
谢谢你的帮助.
凯文
我的站点主页以这种方式连接到jquery-1.3.2.min.js文件:
<SharePoint:ScriptLink language="javascript" name="jquery-1.3.2.min.js"
Defer="true" runat="server"/>
Run Code Online (Sandbox Code Playgroud)
我的内容编辑器Web部件代码如下所示:
<style type="text/css">
#box
{
background: red;
width: 300px;
height: 300px;
display: none;
}
</style>
<script type ="text/javascript">
$(function() {
$('a').click(function() {
$('#box').slideDown(2000);
});
})
</script>
<div id="box">
<h1>This is text in the box</h1>
</div>
<a href="#">Display Box</a><br />
Run Code Online (Sandbox Code Playgroud)
小智 7
最近我遇到了一个问题,我认为它可能对某人有所帮助.
在SharePoint头标记中,如果您放置脚本标记,如
<script language="javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"/>
Run Code Online (Sandbox Code Playgroud)
然后jQuery不工作,但如果你喜欢
<script language="javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
看到</script>
差异然后它正在发挥作用.
我很惊讶!