1
1

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.

全てHTMLエレメントのスタイルを変更する

Posted at

1。HTML DOMを使いって、全てHTMLエレメントのスタイルを変更する

var key = "..."
var value = "..."

keyはCSSプロパティです。はCSSプロパティのバリュー
です。例:

var key = "margin"
var value = "10px"

keyがある全てHTMLエレメントのスタイルを検査する。

$('*').filter(function () {
     return $(this).css(key)
})

コンディションで全てHTMLエレメントのスタイルを検査する。

$('*').filter(function () {
     return $(this).css(key)==value
})

全てHTMLエレメントのスタイルを変更する

$('*').filter(function () {
     return $(this).css(key, value)
})

classid

$('#abc *').filter(function () {
     return $(this).css('margin')
})

2。Regexを使いって、全てHTMLエレメントのinlineCSSを変更する

innerHTMLはRegexでinlineCSSを変更する

var html = document.body.innerHTML;
html = html.replace(/(?=[^<>]+:|\s*")margin:(?=[^<>]+:|\s*")/g, '');
$(document.body).html();
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?