SitePoint Sponsor

User Tag List

Results 1 to 21 of 21

Thread: span in prompt

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    span in prompt

    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the button to demonstrate the prompt box.</p>
    
    <button onclick="myFunction()">Try it</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction()
    {
    var x;
    
    var nr=prompt("Please enter number","number1");
    var nr2=prompt("Please enter number","number2");
    
    
    
    
      
      x=parseInt(nr)+parseInt(nr2)+<span style="color:blue">nr-nr2</span> 
    
      document.getElementById("demo").innerHTML=x;
      
    }
    </script>
    
    </body>
    </html>

    Please, what is wrong here?
    I just want to get second number couored blue...
    Can someone help me?
    Many thanks!
    Last edited by Pullo; Dec 21, 2013 at 05:56. Reason: Added code tags


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •