Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. The problem of JavaScript position

The problem of JavaScript position

Scheduled Pinned Locked Moved JavaScript
questionjavascriptsalestoolshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Ted K 1
    wrote on last edited by
    #1

    Dear All, I got a question! why can't i put the script code after the div with class="jumbotorn" ? I have tried to put it in the , and it's work! Please helps me! THANKS!

    <body>
    <div class="jumbotron">
    <div align="center">
    <h1 style="font-family:微軟正黑體;">行銷神語</h1>
    <p id="pharse"></p>
    <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
    </div>
    </div>

    <script>
    	function makePharse(){
    		var word1 = \["24/7","Multi-Tier","30,000 foot","B-to-B","Win-Win","Customer"\];
    		var word2 = \["Empowered","Value-Added","Oriented","Focused","Aligned"\];
    		var word3 = \["Process","Solution","Tipping-Point","Strategy","Vision"\];
    		var rand1 = Math.floor(Math.random()\*word1.length);
    		var rand2 = Math.floor(Math.random()\*word2.length);
    		
    		var pharse = word1\[rand1\]+""+word2\[rand2\]+"";
    		var pharseElement = document.getElementById("pharse");
    		pharseElement.innerHTML = pharse;
    		pharseElement.innerHTML = "TESt";
    		
    	}
    	
    
    </script>
    

    </body>

    P C 2 Replies Last reply
    0
    • T Ted K 1

      Dear All, I got a question! why can't i put the script code after the div with class="jumbotorn" ? I have tried to put it in the , and it's work! Please helps me! THANKS!

      <body>
      <div class="jumbotron">
      <div align="center">
      <h1 style="font-family:微軟正黑體;">行銷神語</h1>
      <p id="pharse"></p>
      <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
      </div>
      </div>

      <script>
      	function makePharse(){
      		var word1 = \["24/7","Multi-Tier","30,000 foot","B-to-B","Win-Win","Customer"\];
      		var word2 = \["Empowered","Value-Added","Oriented","Focused","Aligned"\];
      		var word3 = \["Process","Solution","Tipping-Point","Strategy","Vision"\];
      		var rand1 = Math.floor(Math.random()\*word1.length);
      		var rand2 = Math.floor(Math.random()\*word2.length);
      		
      		var pharse = word1\[rand1\]+""+word2\[rand2\]+"";
      		var pharseElement = document.getElementById("pharse");
      		pharseElement.innerHTML = pharse;
      		pharseElement.innerHTML = "TESt";
      		
      	}
      	
      
      </script>
      

      </body>

      P Offline
      P Offline
      Peter Leow
      wrote on last edited by
      #2

      I do not agree that your script will work inside the head. makePharse() is a function that you have to call it on some event say button click, so add an onclick to your button:

      <a class="btn btn-primary btn-lg" href="#" role="button" onclick="makePharse()">Learn more</a>

      and comment out the

      //pharseElement.innerHTML = "TESt";

      1 Reply Last reply
      0
      • T Ted K 1

        Dear All, I got a question! why can't i put the script code after the div with class="jumbotorn" ? I have tried to put it in the , and it's work! Please helps me! THANKS!

        <body>
        <div class="jumbotron">
        <div align="center">
        <h1 style="font-family:微軟正黑體;">行銷神語</h1>
        <p id="pharse"></p>
        <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
        </div>
        </div>

        <script>
        	function makePharse(){
        		var word1 = \["24/7","Multi-Tier","30,000 foot","B-to-B","Win-Win","Customer"\];
        		var word2 = \["Empowered","Value-Added","Oriented","Focused","Aligned"\];
        		var word3 = \["Process","Solution","Tipping-Point","Strategy","Vision"\];
        		var rand1 = Math.floor(Math.random()\*word1.length);
        		var rand2 = Math.floor(Math.random()\*word2.length);
        		
        		var pharse = word1\[rand1\]+""+word2\[rand2\]+"";
        		var pharseElement = document.getElementById("pharse");
        		pharseElement.innerHTML = pharse;
        		pharseElement.innerHTML = "TESt";
        		
        	}
        	
        
        </script>
        

        </body>

        C Offline
        C Offline
        Cai Yang
        wrote on last edited by
        #3

        中国人?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups