# :data() Selector
# :data() Selector
Categories: [Selectors](http://www.css88.com/jquery-ui-api/category/selectors/ "View all posts in Selectors") | [UI Core](http://www.css88.com/jquery-ui-api/category/ui-core/ "View all posts in UI Core")
**Description:** 选择数据已存储在指定的键下的元素。
- #### jQuery( ":data(key)" )
**key:** 数据的键。
表达式 `$( "div:data(foo)")` 匹配一个通过 `.data( "foo", value )` 存储数据的 `<div>`。
## Example:
#### 选择带有数据的元素,改变它们的背景颜色。
```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>data demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<style>
div {
width: 100px;
height: 100px;
border: 1px solid #000;
float: left;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<script>
$( "#one" ).data( "color", "blue" );
$( "#three" ).data( "color", "green" );
$( ":data(color)" ).each(function() {
var element = $( this );
element.css( "backgroundColor", element.data( "color" ) );
});
</script>
</body>
</html>
```
- 介紹
- 索引
- Effects
- .addClass()
- Blind Effect
- Bounce Effect
- Clip Effect
- Color Animation
- Drop Effect
- Easings
- .effect()
- Explode Effect
- Fade Effect
- Fold Effect
- .hide()
- Highlight Effect
- Puff Effect
- Pulsate Effect
- .removeClass()
- Scale Effect
- Shake Effect
- .show()
- Size Effect
- Slide Effect
- .switchClass()
- .toggle()
- .toggleClass()
- Transfer Effect
- Effect Core
- Interactions
- Draggable Widget
- Droppable Widget
- Mouse Interaction
- Resizable Widget
- Resizable Widget
- Selectable Widget
- Sortable Widget
- Method Overrides
- .focus()
- .position()
- Methods
- .disableSelection()
- .enableSelection()
- .removeUniqueId()
- .scrollParent()
- .uniqueId()
- .zIndex()
- Selectors
- :data() Selector
- :focusable Selector
- :tabbable Selector
- Theming
- CSS 框架(CSS Framework)
- Icons
- Stacking Elements
- UI Core
- Utilities
- Widget Factory
- Widget Plugin Bridge
- Widgets
- Accordion Widget
- Autocomplete Widget
- Button Widget
- Datepicker Widget
- Dialog Widget
- Menu Widget
- Progressbar Widget
- Slider Widget
- Spinner Widget
- Tabs Widget
- Tooltip Widget
- upscayl使用教程