0

Dealing with SharePoint 2007 Calendar view. We are trying some javascript via a content editor to hide the "12:00 AM" when viewing the data from a calendar view.

It's only hiding the first instance...all other strings of "12:00 AM" are still showing.

<script type="text/javascript">
var el = document.getElementById('MontlyViewDefault_CalendarView');
el.innerHTML = el.innerHTML.replace("12:00 AM", "");
</script>

Trying this too, but no luck as well:

var el = document.getElementById('MontlyViewDefault_CalendarView');

for(var i=0; i < el.length; i++) {
      el[i].innerHTML = el[i].innerHTML.replace("12:00 AM","");
    }

Got it with:

<script type="text/javascript">
var el = document.getElementsByTagName('a');

for(var i=0; i < el.length; i++) {
      el[i].innerHTML = el[i].innerHTML.replace("12:00 AM","");
    }
</script>
  • 3
    getElementById is only going to return the first instance, you need a different selector to get all items – Eric Alexander Feb 20 '15 at 16:46
1

I resolved it with:

<script type="text/javascript">
var el = document.getElementsByTagName('a');

for(var i=0; i < el.length; i++) {
      el[i].innerHTML = el[i].innerHTML.replace("12:00 AM","");
    }
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.