I would not use id's for that purpose. Your users might want to use id's on the elements for another reason. Also, using extra attributes would prevent validation, and again, some users might want that.
I would use classes. I think namespacing them for your library would be nice, so for instance you could use classnames like fooLibButton
or fooLibList
or something. Since an element can have multiple classes this won't cause the problems an id will cause.
If you don't use jquery, you can still easily get those elements:
/*
* addLoadEvent based upon this blog article:
*
* http://simon.incutio.com/archive/2004/05/26/addLoadEvent
*/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {oldonload();func();}
}
}
/*
* As proposed by Bernard Marx on:
* http://www.webmasterworld.com/forum91/1729.htm
*/
function getElementsByCondition(condition,container) {
container = container||document
var all = container.all||container.getElementsByTagName('*')
var arr = []
for(var k=0;k<all.length;k++){
var elm = all[k]
if(condition(elm,k)){
arr[arr.length] = elm
}
}
return arr
}
function checkWetherContainsClass(classname,element){
var classes =
element.className.split(" ");
var found = false;
var k=0;
while(k<classes.length&&classes!=classname){k++;}
return !(k == classes.length);
}
function getElementsByClass(classname,container){
return getElementsByCondition(function(x,y){return checkWetherContainsClass(classname,x);},container);
}
But to answer your question: afaik, no, there is no defacto standard.