我在我的 SharePoint Online 帐户中设置了脚本编辑器 Web 部件。结果在我编辑页面时显示,但在浏览页面时不显示。
这是我正在使用的脚本:
<h3>You got married: <span id="married"></span></h3>
<h3>Adam was born: <span id="adamBorn"></span></h3>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://mysite.sharepoint.com/tech/Scripts/moment-with-langs.js"> </script>
<script>
function setMoments(){
var married = $('#married'),
date = moment("1951-12-05", "YYYY-MM-DD"),
update = function(){
married.html(date.fromNow());
};
update();
var adamBorn = $('#adamBorn'),
date = moment("1992-06-14", "YYYY-MM-DD"),
update = function(){
adamBorn.html(date.fromNow());
};
update();
};
_spBodyOnLoadFunctionNames.push("setMoments");
</script>
我也尝试了使用document.ready,但是浏览页面时仍然不显示结果。