I am using plain javascript , what i want to achieve is , i am using squarespace and they are using jquery cdn for backend but there jquery cdn is not available in frontend , so if we add jquery in backend then there will be conflict so what i am doing is i am adding check that when squarespace dont have squarespace editable class then i am adding jquery cdn and after adding jquery cdn i am adding jquery code . jquery cdn is appended but jquery code is not appending in the script tag that is where i am stuck ,
window.addEventListener('load', function() {
if(document.body.classList.contains('squarespace-editable'))
{
document.getElementById("jquerscript").innerHTML = "Paragraph changed!";
document.getElementById("jquerscriptCode").innerHTML = "Paragraph changed!";
}
else
{
var newScripttwo = document.createElement("script");
newScripttwo.src = "https://code.jquery.com/jquery-1.11.3.min.js";
document.getElementById("jquerscript").appendChild(newScripttwo);
newScript = document.createElement("script");
newScript.onload = function () {
alert('checking');
}
document.getElementById("jquerscriptCode").appendChild(newScript);
}
});
these are two empty div's i am appending javascript code to
<div id="jquerscript"></div>
<div id="jquerscriptCode"></div>
in the jquerscriptCode script tag is appending but the code i am trying to append in between the script tag is not working .
document.getElementById("jquerscript").innerHTML = "Paragraph changed!";
document.getElementById("jquerscriptCpde").innerHTML = "Paragraph changed!";
You wrote code with p (jquerscriptCpde) So change it to o (jquerscriptCode), i think thats your problem, if it didn't solve tell me to read your code again and check for more..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.