web_sys::Document::body function

Example

This example gets the body HtmlElement, dynamically cast the element into a HtmlBodyElement, and use it to set the bgColor of the body.


	pub fn document_body()
	{
		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 = body
		.dyn_into::<web_sys::HtmlBodyElement>()
		.unwrap();
		val.set_bg_color("lightblue");    
	}

Function


	pub fn body(&self)-> Option<HtmlElement>

features/dependencies

Source Code