wrong result of <br />

+1 MAYANK JINDAL · May 3, 2015
I am getting wrong result .Please help me.
<!Doctype HTML>
<html>
    <head>

    </head>
    <body>
           <script type="text/javascript">
                  var x= "mayank";
                  var y =24;
                  document.write(x + " jindal" +  age);
                  function may(x){
                  alert("i" + "<br />"+ " love" + x);
                  }
           </script>
           <form>
           <input type="submit" value ="click me " onclick = 'may("mayank")'>
           </form>
    </body>
</html>

Post a Reply

Replies

Oldest  Newest  Rating
0 Tincu Andrei · May 3, 2015
<!Doctype HTML>
<html>
<head>

</head>
<body>
<script type="text/javascript">
    
var x= "mayank";
var y =24;
    
document.write(x + " jindal " + y);
    
function may(x){
    alert("i \n love" + x);
}
    
</script>
<form>
<input type="submit" value ="click me " onclick = 'may("mayank")'>
</form>
</body>
</html>
0 zhang yida · May 3, 2015
the <br/>  tag is ok for html but not the alert, you can use "\n" with alert  or document.write() with <br/>
0 MAYANK JINDAL · May 3, 2015
problem are  -- br tag is not working 
0 MAYANK JINDAL · May 3, 2015
same problem after putting in head.
0 zhang yida · May 3, 2015
and replace the age with y
+1 zhang yida · May 3, 2015
and you  can also replace the <br>  with "\n"
+1 zhang yida · May 3, 2015
Oh my god !! you should  put the script in the body? believe me it belongs to the head
  • 1

Javascript

106,963 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators