javascript - This jQuery, Moment.js script won't display in SharePoint Online script editor web part, any ideas why? -
I have set up a script editor Web part in my SharePoint online account. The results show that when I am Page Edit , but not when Browsing page Here's the script I'm using: I also tried to use the document. Already, but while browsing the page the results are still not displayed. To ensure this part of the code, In addition, your code can be simplified: Because your script is after both fields, then there is no need to use
& lt; H3 & gt; You are married: & lt; Span id = "married" & gt; & Lt; / Span & gt; & Lt; / H3 & gt; & Lt; H3 & gt; Adam was born: & lt; Span id = "adamborn" & gt; & Lt; / Span & gt; & Lt; / H3 & gt; & Lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "https://mysite.sharepoint.com/tech/Scripts/moment-with-langs.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Function SetMoments () {Wedding = $ ('# Married'), Date = Moment ("1955-12-05", "YYYY-MM-DD"), Update = function () {married.html (date. FromNow ()); }; Updates(); Var adamBorn = $ ('# adamBorn'), date = moment ("1992-06-14", "YYYY-MM-DD"), update = function () {adamBorn.html (date.fromNow ()); }; Updates(); }; _spBodyOnLoadFunctionNames.push ("setMoments"); & Lt; / Script & gt;
warnings () Tried to debug to setMoments () before? Can be reached at some point?
& lt; Script & gt; $ ('# Married'). Html (moment ("1951-12-05", "YYYY-MM-DD"). FromNow ()); $ ('#edembern'). Html (moment ("1992-06-14", "YYYY-MM-DD"). FromNow ()); & Lt; / Script & gt;
$ (documen). or
_spBodyOnLoadFunctionNames .
Comments
Post a Comment