あるページのソースを見ていたら
サーチ

スクリプトタグの中に、


$('hoge')

;


という記述を発見!!2

これはなんぞやはてなマーク

調べてみたら目

javascript のライブラリ mootools で、


document.getElementById('hoge');


という意味らしいぼーぜん

確かにいちいち書くのめんどくさいよね(*´・ω・`)


便利合格
要素の位置を知りたい時

element.offsetTop

element.offsetLeft

要素の幅・高さを知りたい時


element.offsetWidth
element.offsetHeight


これでばっちりと思っていたら。。。
実はかなりブラウザ依存があるらしい びっくり


以下のスクリプトを書いて実験してみたダウンダウン
(とりあえずFF3とIE6で)

<script type="text/javascript">
<!--
function getElementParameter(el){
var w = el.offsetWidth;
var h = el.offsetHeight;
var top = el.offsetTop;
var left = el.offsetLeft;

alert("offsetWidth=" + w);
alert("offsetWidth=" + h);
alert("offsetWidth=" + top);
alert("offsetWidth=" + left);
}
// -->
</script>

呼び出し側
onclick="getElementParameter(this);"


実験結果

FF3
offsetWidth=100
offsetHeight=19
offsetTop=224
offsetLeft=48

IE6
offsetWidth=100
offsetHeight=18
offsetTop=200
offsetLeft=40



うわ汗
ホントに違うガーン