jquery - Changing textContent using javascript, Cushy CMS -
ok, i'm going bad rep here asking many questions. have javascript dynamically changes content on page. works fine. issue need able tag text 'class="cushycms"' in order allow access site owner easy content changes. here basic code script, there more 1 set give idea of i'm doing. tried adding class tag inside innerhtml, cushy couldn't see it.
<script language="javascript" type="text/javascript"> function changetext(idelement) { if(idelement==0){ document.getelementbyid('tagmain').innerhtml ='<class="cushycms">default text display on page load.'; document.getelementbyid('tagtext').innerhtml ='<class="cushycms">more default body text on page load.'; } </script>
i looking way put these text fields in hidden div , pull textcontent there. example of section works cushy
<h2 class="cushycms">preventative maintanence</h2>
i'm beginning hang of javascript, though java primary language. want more rounded langauge skills trying leanr as can. in advance help.
cushy cms requires actual html in order edit. use following:
html
<p id="tagmain-replace" class="cushycms" style="display:none;"></p> <p id="tagmain">default text</p>
js
var newtext = document.getelementbyid('tagmain-replace').innertext; if( newtext != ''){ document.getelementbyid('tagmain').innertext = newtext; }
i suggest changing ids better work project.
Comments
Post a Comment