SYNCERのロゴ
アイキャッチ画像

Document.createProcessingInstruction() - 処理命令ノードを作成する

createProcessingInstruction()は、Documentのメソッドです。処理命令ノード(ProcessingInstruction)を新しく作成します。XML文書向けのメソッドです。

概要

名前
createProcessingInstruction
所属
Document
IDL
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
仕様書
https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction

説明

第1引数(target)には、ターゲットを指定します。

第2引数(data)には、内容を指定します。

返り値は、新しく作成した要素(ProcessingInstruction)です。

チュートリアル

処理命令ノードを作成する例です。

document.createProcessingInstruction( "xml-stylesheet", 'href="style.css" type="text/css"' ) ;

デモ

Document.createProcessingInstruction()のデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<body>
<script>
var processingInstruction = document.createProcessingInstruction( "xml-stylesheet", 'href="style.css" type="text/css"' ) ;

console.log( processingInstruction ) ;
document.body.appendChild( new Text( processingInstruction ) ) ;
</script>
</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
9+
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年10月7日 (土)
コンテンツを公開しました。