Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add bower.json

  • Loading branch information...
commit 2bd048249047ad7e8a3219f7e6409a1acc467445 1 parent 8a89c30
@mathiasbynens authored
View
3  .gitattributes
@@ -1 +1,2 @@
-* crlf=input
+# Automatically normalize line endings for all text-based files
+* text=auto
View
2  .gitignore
@@ -1 +1 @@
-.DS_Store
+.DS_Store
View
28 README.md
@@ -6,20 +6,24 @@ This plugin simplifies the use of HTML5 custom data attributes in your jQuery co
### HTML
- <p id="foo" data-time="9 AM">…</p>
+```html
+<p id="foo" data-time="9 AM">…</p>
+```
### jQuery
- // You can perfectly use this:
- $('#foo').attr('data-time'); // '9 AM'
- // But I prefer to do it this way, especially when dealing with a lot of data-*
- $('#foo').dataAttr('time'); // '9 AM'
- // Just like $.attr(), $.dataAttr() can be used as a setter
- $('#foo').dataAttr('time', '3 PM');
- // Computed data-* attribute values are possible as well
- $('p').dataAttr('id', function() {
- return this.id;
- }); // p data-id="foo"
+```
+// You can perfectly use this:
+$('#foo').attr('data-time'); // '9 AM'
+// But I prefer to do it this way, especially when dealing with a lot of data-*
+$('#foo').dataAttr('time'); // '9 AM'
+// Just like $.attr(), $.dataAttr() can be used as a setter
+$('#foo').dataAttr('time', '3 PM');
+// Computed data-* attribute values are possible as well
+$('p').dataAttr('id', function() {
+ return this.id;
+}); // p data-id="foo"
+```
## Useful?
@@ -33,4 +37,4 @@ Since `.dataAttr('foo')` minifies to `.x('foo')`, while `.attr('data-foo')` mini
## Credits
-_– [Mathias](http://mathiasbynens.be/)_
+_– [Mathias](http://mathiasbynens.be/)_
View
11 bower.json
@@ -0,0 +1,11 @@
+{
+ "name": "jquery-custom-data-attributes",
+ "version": "1.0.0",
+ "main": "jquery.dataAttr.js",
+ "dependencies": {
+ "jquery": "<=1.4.1"
+ },
+ "ignore": [
+ ".*"
+ ]
+}
View
11 jquery.dataAttr.js
@@ -1,9 +1,4 @@
-/*!
- * HTML5 custom data attributes plugin for jQuery v1.0
- * @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery
- * @description An easy setter/getter for HTML5 data-* attributes
- * @author Mathias Bynens <http://mathiasbynens.be/>
- */
-jQuery.fn.dataAttr = function(attr, val) {
+/*! http://git.io/jcda v1.0.0 by @mathias */
+;jQuery.fn.dataAttr = function(attr, val) {
return val ? this.attr('data-' + attr, val) : this.attr('data-' + attr);
-};
+};
View
9 jquery.dataAttr.min.js
@@ -1,7 +1,2 @@
-/*!
- * HTML5 custom data attributes plugin for jQuery v1.0
- * @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery
- * @description An easy setter/getter for HTML5 data-* attributes
- * @author Mathias Bynens <http://mathiasbynens.be/>
- */
-jQuery.fn.dataAttr=function(a,v){return v?this.attr('data-'+a,v):this.attr('data-'+a)};
+/*! http://git.io/jcda v1.0.0 by @mathias */
+;jQuery.fn.dataAttr=function(a,b){return b?this.attr("data-"+a,b):this.attr("data-"+a)};
Please sign in to comment.
Something went wrong with that request. Please try again.