This example demonstrates the use of document.query_selector_all to select multiple <p> elements.
The method returns a Result<NodeList, JsValue>. The inner text of the first Node in the list is set to the length of the NodeList.
pub fn document_query_selector_all()
{
let window = web_sys::window().expect("global window does not exists");
let document = window.document().expect("expecting a document on window");
let val = document.query_selector_all("p")
.unwrap()
.dyn_into::<web_sys::NodeList>()
.unwrap();
let num_p = val.length();
val.item(0)
.unwrap()
.dyn_into::<web_sys::HtmlElement>()
.unwrap()
.set_inner_text(&num_p.to_string());
//Using set_text_content in Node
//val.item(0).unwrap().set_text_content(Some(&num_p.to_string()));
}
pub fn query_selector_all(&self, selectors: &str) -> Result<NodeList, JsValue>