[][src]Struct web_sys_query::Element

pub struct Element(_);

Element with jQuery-like methods.

Implementations

impl Element[src]

Attribute manipulation methods

pub fn add_class(&self, class: &str) -> Result<(), Error>[src]

Add CSS class.

pub fn attr(&self, key: &str) -> Option<String>[src]

Return the matching attribute, if found.

pub fn set_attr(&self, key: &str, value: &str) -> Result<(), Error>[src]

Set the attribute to the specified value.

pub fn has_class(&self, class: &str) -> bool[src]

Check if element has a matching CSS class.

pub fn html(&self) -> String[src]

Get the inner HTML of the element.

pub fn set_html(&self, html: &str)[src]

Set the inner HTML of the element.

pub fn remove_attr(&self, key: &str) -> Result<(), Error>[src]

Remove the attribute.

pub fn remove_class(&self, class: &str) -> Result<(), Error>[src]

Remove CSS class from list.

pub fn toggle_class(&self, class: &str) -> Result<bool, Error>[src]

Return the matching attribute, if found.

pub fn val(&self) -> Result<String, Error>[src]

pub fn val_f64(&self) -> Result<f64, Error>[src]

pub fn val_i32(&self) -> Result<i32, Error>[src]

pub fn set_val(&self, value: &str) -> Result<(), Error>[src]

pub fn set_val_f64(&self, value: f64) -> Result<(), Error>[src]

pub fn set_val_i32(&self, value: i32) -> Result<(), Error>[src]

impl Element[src]

Event handlers

pub fn on(&self, event: Event) -> Result<Function, Error>[src]

pub fn set_on(
    &self,
    event: Event,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_off(&self, event: Event) -> Result<(), Error>[src]

pub fn set_blur(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_change(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_click(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_context_menu(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_dbl_click(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_focus(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_key_down(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_key_press(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_key_up(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_load(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_down(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_enter(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_leave(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_move(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_out(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_over(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_mouse_up(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_resize(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_scroll(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_select(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

pub fn set_submit(
    &self,
    callback: &Closure<dyn FnMut(Event)>
) -> Result<(), Error>
[src]

impl Element[src]

pub fn serialize_array<T, V>(&self) -> Result<T, Error> where
    T: FromIterator<(String, V)>,
    V: From<String>, 
[src]

Serialize a form into a data structure that holds a key-value type.

The generic return type can be anything that supports the trait bounds, for example Vec<(String, String)> or HashMap<String, String>. To get a jQuery-compatible return type, use the FormData type that is provided by this crate.

impl Element[src]

DOM manipulation

pub fn text(&self) -> Result<String, Error>[src]

Get the inner text.

pub fn set_text(&self, text: &str) -> Result<(), Error>[src]

Set the inner text.

impl Element[src]

Traversing methods

pub fn children(&self, selectors: Option<&str>) -> Result<Collection, Error>[src]

pub fn closest(&self, selectors: &str) -> Result<Option<Self>, Error>[src]

Find the closets element that matches the selector.

pub fn filter(&self, selectors: &str) -> Result<Option<Self>, Error>[src]

Filter if the element matches the selector.

pub fn find(&self, selectors: &str) -> Result<Collection, Error>[src]

Find elements by selectors.

pub fn first(&self) -> Element[src]

pub fn has(&self, selectors: &str) -> Result<Option<Self>, Error>[src]

Filter if a decendant matches the selector.

pub fn is(&self, selectors: &str) -> Result<bool, Error>[src]

Check if the element matches the selectors.

pub fn last(&self) -> Element[src]

pub fn next(&self, selectors: Option<&str>) -> Result<Option<Self>, Error>[src]

pub fn not(&self, selectors: &str) -> Result<Option<Self>, Error>[src]

Filter if the element does not matche the selector.

pub fn parent(&self) -> Option<Self>[src]

pub fn prev(&self, selectors: Option<&str>) -> Result<Option<Self>, Error>[src]

impl Element[src]

pub fn descendants(&self) -> Collection[src]

pub fn dyn_ref<T: JsCast>(&self) -> Result<&T, Error>[src]

Trait Implementations

impl AsRef<Element> for Element[src]

impl Clone for Element[src]

impl Debug for Element[src]

impl Deref for Element[src]

type Target = Element

The resulting type after dereferencing.

impl DerefMut for Element[src]

impl Display for Element[src]

impl From<Element> for Element[src]

impl From<Element> for Element[src]

impl From<Element> for Collection[src]

impl FromIterator<Element> for Collection[src]

impl<'_> TryFrom<&'_ Document> for Element[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Document> for Element[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Event> for Element[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryInto<&'a HtmlElement> for &'a Element[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.