Inserting a div into another static div for mobile Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!How do I redirect to another webpage?How to insert an item into an array at a specific index (JavaScript)?How to check if a string “StartsWith” another string?Creating a div element in jQueryHow do I include a JavaScript file in another JavaScript file?How to move an element into another element?How to replace innerHTML of a div using jQuery?What is the best way to detect a mobile device in jQuery?Best place to insert the Google Analytics codeIs the recommendation to include CSS before JavaScript invalid?

How to do this path/lattice with tikz

iPhone Wallpaper?

What happens to sewage if there is no river near by?

Do I really need recursive chmod to restrict access to a folder?

Why is black pepper both grey and black?

How to find all the available tools in macOS terminal?

How much radiation do nuclear physics experiments expose researchers to nowadays?

Bonus calculation: Am I making a mountain out of a molehill?

Sorting numerically

List *all* the tuples!

What would be the ideal power source for a cybernetic eye?

Storing hydrofluoric acid before the invention of plastics

Did Xerox really develop the first LAN?

Output the ŋarâþ crîþ alphabet song without using (m)any letters

Models of set theory where not every set can be linearly ordered

What LEGO pieces have "real-world" functionality?

What is the musical term for a note that continously plays through a melody?

How does a Death Domain cleric's Touch of Death feature work with Touch-range spells delivered by familiars?

Gastric acid as a weapon

Problem drawing boxes with arrows in tikZ

How can players work together to take actions that are otherwise impossible?

ListPlot join points by nearest neighbor rather than order

Why does Python start at index -1 when indexing a list from the end?

Why constant symbols in a language?



Inserting a div into another static div for mobile



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!How do I redirect to another webpage?How to insert an item into an array at a specific index (JavaScript)?How to check if a string “StartsWith” another string?Creating a div element in jQueryHow do I include a JavaScript file in another JavaScript file?How to move an element into another element?How to replace innerHTML of a div using jQuery?What is the best way to detect a mobile device in jQuery?Best place to insert the Google Analytics codeIs the recommendation to include CSS before JavaScript invalid?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a WordPress site and I want to add second header line after the mobile header div.



When I insert the code in Chrome console with device toolbar as a mobile device, it works perfectly.



$(".headerMobileDiv").append("<div class='container'> Sample Text </div>");


However when I try to add this code into header or footer section, it doesn't work. There is no problem with the implementation of js code.










share|improve this question
























  • It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

    – Rory McCrossan
    Mar 8 at 16:36











  • Is there any error in the console on your mobile device?

    – Ferrybig
    Mar 8 at 16:40

















1















I have a WordPress site and I want to add second header line after the mobile header div.



When I insert the code in Chrome console with device toolbar as a mobile device, it works perfectly.



$(".headerMobileDiv").append("<div class='container'> Sample Text </div>");


However when I try to add this code into header or footer section, it doesn't work. There is no problem with the implementation of js code.










share|improve this question
























  • It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

    – Rory McCrossan
    Mar 8 at 16:36











  • Is there any error in the console on your mobile device?

    – Ferrybig
    Mar 8 at 16:40













1












1








1








I have a WordPress site and I want to add second header line after the mobile header div.



When I insert the code in Chrome console with device toolbar as a mobile device, it works perfectly.



$(".headerMobileDiv").append("<div class='container'> Sample Text </div>");


However when I try to add this code into header or footer section, it doesn't work. There is no problem with the implementation of js code.










share|improve this question
















I have a WordPress site and I want to add second header line after the mobile header div.



When I insert the code in Chrome console with device toolbar as a mobile device, it works perfectly.



$(".headerMobileDiv").append("<div class='container'> Sample Text </div>");


However when I try to add this code into header or footer section, it doesn't work. There is no problem with the implementation of js code.







javascript jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 16:40









Rory McCrossan

251k29217254




251k29217254










asked Mar 8 at 16:34









Berk ŞENGÜLBerk ŞENGÜL

133




133












  • It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

    – Rory McCrossan
    Mar 8 at 16:36











  • Is there any error in the console on your mobile device?

    – Ferrybig
    Mar 8 at 16:40

















  • It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

    – Rory McCrossan
    Mar 8 at 16:36











  • Is there any error in the console on your mobile device?

    – Ferrybig
    Mar 8 at 16:40
















It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

– Rory McCrossan
Mar 8 at 16:36





It sounds like you need to put your code in a document.ready event handler, or execute it just before the </body> tag

– Rory McCrossan
Mar 8 at 16:36













Is there any error in the console on your mobile device?

– Ferrybig
Mar 8 at 16:40





Is there any error in the console on your mobile device?

– Ferrybig
Mar 8 at 16:40












2 Answers
2






active

oldest

votes


















0














$( document ).ready(function() 
$(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
);


By default, JavaScript doesn't know when to execute: you have to tell it when. This example will execute on $(document).ready() which means when the page is done loading.






share|improve this answer






























    1














    Perhaps you need to wrap in something like,



    $(document).ready(function() 
    $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
    );


    the element you're trying to append to may not have loaded yet






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067315%2finserting-a-div-into-another-static-div-for-mobile%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      $( document ).ready(function() 
      $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
      );


      By default, JavaScript doesn't know when to execute: you have to tell it when. This example will execute on $(document).ready() which means when the page is done loading.






      share|improve this answer



























        0














        $( document ).ready(function() 
        $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
        );


        By default, JavaScript doesn't know when to execute: you have to tell it when. This example will execute on $(document).ready() which means when the page is done loading.






        share|improve this answer

























          0












          0








          0







          $( document ).ready(function() 
          $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
          );


          By default, JavaScript doesn't know when to execute: you have to tell it when. This example will execute on $(document).ready() which means when the page is done loading.






          share|improve this answer













          $( document ).ready(function() 
          $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
          );


          By default, JavaScript doesn't know when to execute: you have to tell it when. This example will execute on $(document).ready() which means when the page is done loading.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 16:42









          dmanexedmanexe

          48241034




          48241034























              1














              Perhaps you need to wrap in something like,



              $(document).ready(function() 
              $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
              );


              the element you're trying to append to may not have loaded yet






              share|improve this answer





























                1














                Perhaps you need to wrap in something like,



                $(document).ready(function() 
                $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
                );


                the element you're trying to append to may not have loaded yet






                share|improve this answer



























                  1












                  1








                  1







                  Perhaps you need to wrap in something like,



                  $(document).ready(function() 
                  $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
                  );


                  the element you're trying to append to may not have loaded yet






                  share|improve this answer















                  Perhaps you need to wrap in something like,



                  $(document).ready(function() 
                  $(".headerMobileDiv").append("<div class='container'> Sample Text </div>");
                  );


                  the element you're trying to append to may not have loaded yet







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 8 at 16:43









                  Zoe

                  13.6k85486




                  13.6k85486










                  answered Mar 8 at 16:42









                  digital-pollutiondigital-pollution

                  74449




                  74449



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067315%2finserting-a-div-into-another-static-div-for-mobile%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко