1

I have a "language switcher" on a Drupal 7 site.

<ul class="language-switcher-locale-url">
    <li class="en first">
        <a class="language-link" xml:lang="en" href="someURL">
            <img class="language-icon" width="26" height="19" title="English" alt="English" src="someURL">
        </a>
    </li>
    <li class="fr active">
        <a class="language-link active" xml:lang="fr" href="someURL">
            <img class="language-icon" width="26" height="19" title="Français" alt="Français" src="someURL">
        </a>
    </li>
    <li class="ru last">
        <a href="someURL" class="language-link" xml:lang="ru">
            <img class="language-icon" src="someURL" width="26" height="19" alt="Русский" title="Русский" />
        </a>
    </li>
</ul>

When some special conditions are true, I want to remove the russian flag.

<script>
jQuery(document).ready(function() {
    var ce;
    ce = jQuery("ul.language-switcher-locale-url > li.ru");
    ce.remove();
    ce = undefined;     
});
</script>

It seems to work, because the flag is removed, Firebug shows no errors in the console and w/ Inspect Element I find that the <li> has been removed. However if I go to Page Source it is still there.

Does this mean jQuery does not remove the element from the DOM? Why is it still in the Page Source? How can I be sure it is completely removed?

color
  • 53
  • 1
  • 7
  • Page source will not be altered only the DOM object will be. – Rajaprabhu Aravindasamy Aug 18 '15 at 09:43
  • what do you mean by page source... if you are not inspecting the live dom but using the view source option... then it will only show the source downloaded from server – Arun P Johny Aug 18 '15 at 09:43
  • The page source is the original html file, jQuery doesn't edit the "page source" html file, it edits the DOM object which is basically a copy of the html file. – Canvas Aug 18 '15 at 10:08

1 Answers1

2

Page source shows you the html that was originally downloaded from the server however you have removed it from the DOM which you confirmed with inspect element.

  • ok. Then bots, crawlers would see and access the link I removed because they get the page as it is before jQuery removes anything? – color Aug 19 '15 at 06:51
  • @color, the link will indeed be in the html response of the server unless you remove it server side. As far as bots it will depend if they process the javascript before crawling the page. Here is a link from google with some info about that https://developers.google.com/webmasters/ajax-crawling/docs/learn-more – ykay says Reinstate Monica Aug 19 '15 at 10:02
  • Tank you, @ykay. I'll see what I can do to hide the links from bots. – color Aug 20 '15 at 06:14