Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 9x | /**
*
* Get an attribute from a DOM-element based on the attribute name.
*
* <example>
:index.html
<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>
:getAttribute.js
it('should demonstrate the getAttribute command', () => {
const form = $('form')
const attr = form.getAttribute('method')
console.log(attr) // outputs: "post"
})
* </example>
*
* @alias element.getAttribute
* @param {String} attributeName requested attribute
* @return {String|null} The value of the attribute, or null if it is not set on the element.
* @uses protocol/elements, protocol/elementIdAttribute
* @type property
*
*/
export default function getAttribute (attributeName) {
return this.getElementAttribute(this.elementId, attributeName)
}
|