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>
サポート状況
Chrome | Firefox | Safari | Edge | IE | Opera | iOS Safari | Android |
---|---|---|---|---|---|---|---|
● | ● | ● | ● | ● 9+ | ● | ● | ● |
関連記事
- Firefoxでドラッグ操作中にプレビューを表示
- Firefoxで、ドラッグ操作中にゴーストプレビューが表示されない時は、ダミーの転送データを作ってあげましょう。
- Document.createTextNode()
- createTextNode()は、Documentのメソッドです。テキストノード(Text)を新しく作成します。
- Document.createDocumentFragment()
- createDocumentFragment()は、Documentのメソッドです。DocumentFragmentを新しく作成します。
- Document.createComment()
- createComment()は、Documentのメソッドです。コメントノード(Comment)を新しく作成します。