<div>1</div>
<div>2</div>
<div>3</div>
<script>
function $() {
return {
id: function (id) {
document.getElementById(id);
this.id = id;
return this;
},
write: function (write) {
document.getElementById(this.id).innerHTML = write
return this;
},
add: function (add) {
document.getElementById(this.id).innerHTML += add
return this;
},
html: function () {
return document.getElementById(this.id).innerHTML
return this;
},
src: function () {
return document.getElementById(this.id).src
return this;
},
tag: function (tag) {
return document.getElementsByTagName(tag)
this.tag = tag
return this;
}
};
}
</script>
Вот написал какое-то подобие библиотеки...пользуйтесь так сказать
Все работает, но вот не могу понять, как взяв все елементы по тегу: $().tag('div') Пременить к ним какое-либо свойство? То есть: $().tag('div')[0].write("что-то") , придется писать новые свойства но уже для tag()? (как для id())