简体   繁体   中英

How to get element id using alias attribute in Mootools

How to get element id using alias attribute in Mootools

<input type="text" alias="school_name" value="" id="test_school" name="test_school">

You can use the $$ function to return an element based on a css selector. You can use the css attribute selector syntax to retrieve elements based on an attribute.

// Returns all inputs with an alias of school_name
var els = $$('input[alias=school_name]');

This will return an array of elements.

You can then do els[0].id to retrieve the id of the first element (or loop through the elements as you see fit)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM