Показать сообщение отдельно
  #21 (permalink)  
Старый 12.01.2012, 14:43
Аватар для 9xakep
сегодня в 12:34|Комментир
Отправить личное сообщение для 9xakep Посмотреть профиль Найти все сообщения от 9xakep
 
Регистрация: 12.04.2011
Сообщений: 1,180

да не) Понял как делать:
<div id='div'>1</div>
<div>2</div>
<script>
function $()  {
return  {
	id: function (id) {
	this.elem = document.getElementById(id);
	this.id = id;
	return this;
	},
	add: function (add) {
	this.elem.innerHTML += add
	return this;
	},
	html: function () {
	return this.elem.innerHTML
	return this;
	},
	tag: function (tag, index) {
	this.elem = document.getElementsByTagName(tag)[index]
	return this;
	},
	write: function (write) {
	this.elem.innerHTML = write
	return this;
	},
	src: function () {
	return this.elem.src
	return this;
	}
			};
		}
alert($().tag('div', 0).html())  /* работает, хотя раньше фаерьаг писал: html() - is not a fuction */
alert($().id('div').html()) // также работает
/* Дело в том, что раньше все ф-ии получали доступ к элементу через docu...ById(this.id)(и если мы брали элемент по тэгу, то ничего не работало), сейчас же весь элемент "храниться" в this.elem */
</script>
__________________
оляля, ололо
Ответить с цитированием