33
35

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 1 year has passed since last update.

JavaScriptとjQueryの相互変換早見表

Posted at

JavaScript ⇔ jQuery 早見表

忘れがちなやつをメモ。正確にはイコールではないが。少しずつ書き足していこう。

変換内容 JavaScript jQuery
ID指定 document.getElementById('foo')
document.querySelector('#foo')
$('#foo')
Class指定 document.getElementsByClassName('foo')
document.querySelector('.foo')
$('.foo')
タグ指定 document.getElementsByTagName('tag') $('tag')
イベント設定 target.addEventListener('event', callback) $(target).on('event', callback)
属性設定 target.setAttribute(name, value) $(target).attr(name, value)
テキスト取得 target.textContent $(target).text()
テキスト設定 target.textContent = string; $(target).text(string)
33
35
2

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
33
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?