How to get, set and select elements with data attributes? <p>I'm having some trouble with data-attributes, I can't get anything to work for some reason so I must be doing something wrong:</p> <p>Set:</p> <pre><code>$('#element').data('data1', '1'); //Actually in my case the data is been added manually </code></pre> <p>Does that make a difference?</p> <p>Get:</p> <pre><code>$('#element').data('data1'); </code></pre> <p>Select:</p> <pre><code>$('#element[data1 = 1]') </code></pre> <p>None of this works for me, am I making this up or how is it?</p>