getAttribute
Get an attribute from a DOM-element based on the attribute name.
Usage
$(selector).getAttribute(attributeName)
Parameters
Name | Type | Details |
---|---|---|
attributeName | String | requested attribute |
Examples
<form action="/submit" method="post" class="loginForm">
<input type="text" name="name" placeholder="username"></input>
<input type="text" name="password" placeholder="password"></input>
<input type="submit" name="submit" value="submit"></input>
</form>
it('should demonstrate the getAttribute command', () => {
const form = $('form')
const attr = form.getAttribute('method')
console.log(attr) // outputs: "post"
})