````javascript
$('.foo');
````
````javascript
$('.foo'); // jQuery
````
````javascript
d3.selectAll('.foo'); // D3
````
````javascript
$('div'); // jQuery
````
````javascript
d3.selectAll('div'); // D3
````
## Attributes
````javascript
$('a').attr('href', 'http://vctr.me')
````
````javascript
d3.selectAll('a').attr('href', 'http://vctr.me')
````
## Styles
````javascript
$('div').css('color', 'red')
````
````javascript
d3.selectAll('div').style('color', 'red')
````
(assuming our document already has 3 divs)
````javascript
$('div');
````

(assuming our document already has 3 divs)
````javascript
d3.selectAll('div');
````

+ instead of collections of elements
+ d3 selectors are collections of (data, element) pairs
+ assuming our document already has 3 divs
(our document has 3 divs)
````javascript
d3.selectAll('div').data([18, 4, 7]);
````

data binding
````javascript
d3.selectAll('div').data(['red', 'green', 'blue'])
.style('color', function(d){ return d})
````
data binding
````javascript
d3.selectAll('div').data([18, 4, 7])
.attr('width', function(d){ return d + '%' })
````
(our document has no divs)
````javascript
d3.selectAll('div').data([18, 4, 7]);
````

+ here's where things get really different
+ assuming our document does NOT have any DIVS
(our document has no divs)
````javascript
d3.selectAll('div').data([18, 4, 7])
.enter().append('div');
````

(our document now has 3 divs)
+ here's where things get epic
+ assuming our document does NOT have any DIVS
(our document has 3 divs)
````javascript
d3.selectAll('div').data([18, 4, 7, 11])
.enter().append('div');
````

(our document now has 4 divs)
+ here's where things get epic
+ assuming our document does NOT have any DIVS
(our document has 4 divs)
````javascript
d3.selectAll('div').data([18, 4])
.exit().remove();
````

(our document now has 2 divs)
+ here's where things get epic
+ assuming our document does NOT have any DIVS
````javascript
d3.selectAll('div').data([8, 3, 7])
.enter().append('div').style('opacity', 0)
````
+ just like with jQuery, the selector methods that don't return a new selector apply to each of the selected data/element pairs.
+ add three divs and set their opacity to 0
````javascript
d3.selectAll('div').data([8, 3, 7])
.enter().append('div').style('opacity', 0)
.text('hello world')
.transition().style('opacity', 1)
````
[demo](demos/demo-opacity.html)
+ add three divs, set their opacity to zero, slowly transition in their opacity
