You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
getComputedStyle とは!? ある要素にどんなスタイルが当たっているかを計算してくれる。便利な関数。 使いかたはめっちゃ簡単! var style = getComputedStyle(element, ''); alert(style.fontSize); // 14px alert(style.color); // rgb(0, 0, 0) ちなみに第二引数は疑似要素の style を取りたい場合に使います。通常は空文字列でいい。 でも、 getComputedStyle はこのままでは IE, Safari では動かない。 Safari では window(グローバル領域) に getComputedStyle は定義されてなくて、 document.defaultView だけに getComputedStyle が定義されている。 ちなみに、 Firefox, Op
Selectors APIのDraftに、matchesSelectorというAPIが定義されていて、現在、WebKitとMinefieldのNightlyに搭載されている。 ただし、ドラフトなのでベンダープレフィックスがついていて、Element#webkitMatchesSelectorやElement#mozMatchesSelectorを使わなければいけない(というより、まだ直接使うには時期尚早だ)。 使い方は簡単。 var paragraphs = document.getElementsByTagName("p"); paragraphs.item(0).webkitMatchesSelector("p"); // true paragraphs.item(1).webkitMatchesSelector("div#main > p"); // <div id="main"><
今更ながらJavaScriptのDOM Core基礎 - 三等兵の付け足し。あの記事長いので重くて開けない。 http://www.w3.org/TR/ElementTraversal/ なんぞ? firstChildとかlastChildとかが便利になったやつ。空白ノードとかコメントノードとか無駄なノードをよけて、要素ノード(nodeTypeが1)しか手を出しません。 やってみる // js var oda = document.getElementById('love_story'); alert(oda.firstChild.nodeType); // 3(テキストノード) alert(oda.firstElementChild.nodeType); // 1 alert(oda.lastChild.nodeType); // 3(テキストノード) alert(oda.lastEle
Document Object ModelElementインスタンスプロパティariaAtomicariaAutoCompleteariaBusyariaCheckedariaColCountariaColIndexariaColIndexText (en-US) Experimental ariaColSpanariaCurrentariaDescriptionariaDisabledariaExpandedariaHasPopupariaHiddenariaKeyShortcutsariaLabelariaLevelariaLiveariaModalariaMultiLineariaMultiSelectableariaOrientationariaPlaceholderariaPosInSetariaPressedariaReadOnlyariaRelevant Non-standa
DocumentConstructorDocument()Instance propertiesactiveElementadoptedStyleSheetsalinkColor Deprecated all Deprecated anchors Deprecated applets Deprecated bgColor Deprecated bodycharacterSetchildElementCountchildrencompatModecontentTypecookiecurrentScriptdefaultViewdesignModedirdoctypedocumentElementdocumentURIdomain Deprecated embedsfeaturePolicy Experimental fgColor Deprecated firstElementChildfo
addEventListener() は EventTarget インターフェイスのメソッドで、ターゲットに特定のイベントが配信されるたびに呼び出される関数を設定します。 対象としてよくあるものは Element、Document、Window ですが、イベントに対応したあらゆるオブジェクトが対象になることができます (XMLHttpRequest など)。 メモ: addEventListener() メソッドは、イベントリスナーを登録するための推奨される方法です。以下のような長所があります。 1 つのイベントに対して複数のハンドラーを追加することができます。これは、ライブラリーや JavaScript モジュール、あるいは他のライブラリーや拡張機能とうまく動作させる必要があるその他の種類のコードで特に有効です。 onXYZ プロパティを使用するのとは対照的に、リスナーが起動されるときの
DOM event delegation is a mechanism of responding to ui-events via a single common parent rather than each child, through the magic of event "bubbling" (aka event propagation). When an event is triggered on an element, the following occurs: The event is dispatched to its target EventTarget and any event listeners found there are triggered. Bubbling events will then trigger any additional event lis
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く