Thierry Posted April 25, 2009 Share Posted April 25, 2009 Was wondering which is better to use, or more reliable across browsers. The object is a div, and it is created with document.createElement. The id will later be used for a few JS functions, but which one should I use? For as far as I can see doing: divRow.SetAttribute("id", "1") is the same as: divRow.id = "1"; Which should I use, and which is faster in performance? Link to comment https://forums.phpfreaks.com/topic/155621-setattributeid1-vs-objectid-1/ Share on other sites More sharing options...
Axeia Posted April 25, 2009 Share Posted April 25, 2009 SetAttribute is a more global approach and I think it has a few issues with older versions of IE for certain attributes, I'd go with .id = Link to comment https://forums.phpfreaks.com/topic/155621-setattributeid1-vs-objectid-1/#findComment-819137 Share on other sites More sharing options...
ToonMariner Posted April 26, 2009 Share Posted April 26, 2009 use jquery... Link to comment https://forums.phpfreaks.com/topic/155621-setattributeid1-vs-objectid-1/#findComment-819470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.