$id
Select element by id or a group of elements by ids for complex and continuous manipulation
$id( id, callback )
id [string/array]
The element id or an array with a group of element ids.callback (optional) [function]
The callback function for each matched elements.
Notes
This is the function to select a element or a group of elements by id for effectively multi-processing them with callback function.
Example
HTML code
<div class="box" id="box1">Hello world!</div> <div class="box" id="box2">Hello world!</div> <div class="box" id="box3">Hello world!</div> <div class="box" id="box4">Hello world!</div> <div class="box" id="box5">Hello world!</div> <button onclick="select_element()">select element</button>
CSS code
.box {
width: 200px;
height: 60px;
font-size: 12px;
background: #5599bb;
padding: 10px;
margin: 5px 0;
}JavaScript code
function select_element()
{
$id( ["box1","box3","box5"], function (item)
{
$text( item, "I found this box" );
$css.set( item, {
"background": "#333",
"color": "#fff",
"width": "350px"
});
$append( item, '<a href="http://qatrix.com">http://qatrix.com</a>' );
});
$id( "box2", function (item)
{
$text( item, "I found this box by id" );
$append( item, '<a href="http://qatrix.com">http://qatrix.com</a>' );
$animate( item, {
"width": "500px"
});
});
}
Demonstration
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!