Jump to content

Invalid Characters


Utherr12

Recommended Posts

var brk = document.createElement('<br />');

This is where javascript console in Chromium triggers the uncaught error.I also have another piece of code like that, and wish to know if it's correct:

field = document.createElement('<input name="q"'+i+' type="text" size="50" \>');

If necessary I can supply the whole function (it's not big). I've seen an example for createElement/appendChild usage ... and I followed the example as seen there, but it looks like it's not good.The exact error message is: "Uncaught Error: INVALID_CHARACTER_ERR: DOM Exception 5"

Link to comment
Share on other sites

OK, thanks a lot, i was wondering if there's a simpler way to add attributes other than get element by tag name with index 0 then element.type = "text", element.value = 6; etc

Link to comment
Share on other sites

Some element nodes have settable properties like "element.value", "element.alt", etc. If the node does not have a settable property, then you can use the "setAttribute" method. jQuery has a method that simplifies this.

$("element").attr({ 		  type: "text",		  title: "jQuery",		  value: "value"	  });

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...