If I load my page and look at the source, I see my elements with the name and id shown in the list above. There's no data-point-value attribute set on them though. I've tried using both prop and attr but neither of them see to add the attribute to the HTML.
attr was the correct thing to use to set data-* attributes on the elements.
If you're using "view source" or similar to view the elements, the changes you're making client-side won't show. "View source" shows the page source as it was delivered from the server (frequently, it goes back to the server and re-retrieves the page, in fact). "View source" does not show you the current state of the DOM. You need to use your browser's live DOM viewer. In Chrome, FireBug, and IE's Dev Tools, this is usually a "DOM" tab or similar.
If you use attr in your code:
$(document).ready(function(e) {
$.each({
"bmsw": 4, "dp": 1, "jmsw": 2, "mhsw": 4, "mp": 5,
"pr": 10, "prrv": 3, "sh": 2, "st": 10, "sw": 2,
"swrv": 1, "ud": 1
}, function(key, value) {
$('#' + key).attr('data-point-value', value);
});
});
Then the element with the id "bmsw" will get a data-point-value attribute with the value "4", the element with the id "dp" will get the value "1", and so on.
Gratuitous complete example: Live Copy | Live Source
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Setting Data Attributes</title>
<style>
span {
border: 1px solid grey;
padding: 0 2px;
cursor: pointer;
}
</style>
</head>
<body>
<p>Each of the below is an element with an <code>id</code> matching its text. Click the element to see the value of its <code>data-point-value</code> attribute.</p>
<p>
<span id="bmsw">bmsw</span>
<span id="dp">dp</span>
<span id="jmsw">jmsw</span>
<span id="mhsw">mhsw</span>
<span id="mp">mp</span>
<span id="pr">pr</span>
<span id="prrv">prrv</span>
<span id="sh">sh</span>
<span id="st">st</span>
<span id="sw">sw</span>
<span id="swrv">swrv</span>
<span id="ud">ud</span>
</p>
<p id="output"></p>
<script>
(function() {
$(document).ready(function(e) {
$.each({
"bmsw": 4, "dp": 1, "jmsw": 2, "mhsw": 4, "mp": 5,
"pr": 10, "prrv": 3, "sh": 2, "st": 10, "sw": 2,
"swrv": 1, "ud": 1
}, function(key, value) {
$('#' + key).attr('data-point-value', value);
});
});
$(document).on("click", "span", function() {
var value = $(this).attr("data-point-value");
$("#output").html(
"The value of <code>" +
this.id +
"</code>'s <code>data-point-value</code> is <code>" +
value +
"</code>"
);
});
})();
</script>
</body>
</html>