JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-lightness/jquery-ui.css">
<div id="d5000">div 5000</div>
<div id="d5001">div 5001</div>
<div id="d5002">div 5002</div>
JavaScript
function clickEvents(items) {
for (var r = 0; r < items.length; r++) {
// removed the stray "+" at the end
var omega = items[r].id;
// concatenate "#" to the ID for a proper ID selector
(function(o) {
$('#' + o).click(function() {
// You were missing the second + operator in this concatenation
alert('Thanks for adding item number #' + o + ' to your cart!');
});
})(omega);
}
}
// Modify IDs so that they do not start with a number
var obj = {
"Items" : [{
"header": "apple",
"id": "d5000"
}, {
"header": "banana",
"id": "d5001"
}, {
"header": "pear",
"id": "d5002"
}]
};
// call the clickEvents() passing in the Items from the obj variable
clickEvents(obj.Items);