0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dotinstall 昔のjavascript入門メモ

Posted at

概要

昔あったレッスンの覚え書きをコピペしただけです。自分用保管。

別のページに飛ばす

window.location.href = 'http://dotinstall.com';

ブラウザの高さ幅を取得

console.log(window.outerHeight);

テキストを変更する

e.textContent = 'hello';

文字色を赤に

e.style.color = 'red';

スタイルを適用(スタイルを作るときはドットを忘れずに)

e.className = 'myStyle';

タグを作る

var greet = document.createElement('p');

テキストを作る

var text = document.createTextNode('hello world');

タグを作って文字を埋める

var greet = document.createElement('p');
var text = document.createTextNode('hello world');
document.body.appendChild(greet).appendChild(text);

イベントを設定する

document.getElementById('add').addEventListener('click',function(){
//クリックするたび文字を追加する
var greet = document.createElement('p');
var text = document.createTextNode('hello world');
document.body.appendChild(greet).appendChild(text);
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?