www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Create Line Break Tag (<br>)

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    93

    resolved [RESOLVED] Create Line Break Tag (<br>)

    I am wanting to put a line break between dynamically inserted elements on a web page. Below is some sample code....
    Code:
    alert("HELLO1");
    	var myBr = document.createElement('<br>');
    alert("HELLO2");
    	xValueCell.appendChild(myBr);
    	var myChangeText = document.createTextNode('Reason for Change: ');
    	xValueCell.appendChild(myChangeText);
    This works fine in FF and IE, but Chrome and Opera break when I try and create the <br> element (HELLO1 prints, but HELLO2 does not).
    Anybody know a better/cross-browser way to do this?

    Thanks

  2. #2
    Join Date
    May 2009
    Posts
    150
    Use 'br', not '<br>', you specify the type of tag, not the full markup for the tag. Also, it worked fine your way in Opera here.

  3. #3
    Join Date
    Oct 2006
    Posts
    93
    D'oh! That was it. Working in Chrome and Opera now.

    Somehow I coudn't see the problem, even though within the same code I am also creating inputs which I did correctly.

    Thanks a ton!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles