web_sys::Document::create_element_ns function

Example

This example creates a div element with a http://www.w3.org/1999/xhtml namespace. The namespace is used to identify which type of XML this tag node belongs to.

Valid namespace:

http://www.w3.org/1999/xhtml for HTML

http://www.w3.org/2000/svg for SVG


	pub fn document_create_element_ns()
	{
		let window = web_sys::window().expect("global window does not exists");    
		let document = window.document().expect("expecting a document on window");
		let body = document.body().expect("document expect to have have a body");
		let val = document
				.create_element_ns(Some("http://www.w3.org/1999/xhtml"),"div")
				.unwrap();
		val.set_inner_html("Hello World from create_element_ns.");
		body.append_child(&val).unwrap();
	}

Function


	pub fn create_element_ns(&self, namespace: Option<&str>, 
							qualified_name: &str) 
							-> Result<Element, JsValue>

features/dependencies

Source Code