简体   繁体   中英

HTML tags inside Javascript function

I want to include a break tag inside the second for loop..How can i do that..can anyone help me in this...I have no idea why this code is not working when i open it in a browser

   <html>
<head>
<title>Object oriented Java Script</title>
<script>
var obj={};
function Obj(name,id)
{
this.name=name;
this.id=id;
}
obj["1"]=new Obj('deena','2345');
obj["2"]=new Obj('diana','2346');
obj["3"]=new Obj('dolphin','2347');
</script>
</head>
<body>
<script>
for(var element in obj)
{
for(var prop in obj[element])
{
alert(element+"\n"+prop+"="+star[element][prop]);
}
}
</script>
</body>
</html>

I think you want to put a newline character, not a break.

alert(element+"\n"+prop="="+star[element][prop]);

Where \\n puts a newline between the element and the prop= portion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM