This can be done with the jQuery attr() method:
var someValue = 2560;
$('.priceinfo.col5').attr('data-price', someValue);
You can set any attribute, including custom attributes such as HTML5 data- attributes, using attr().
You can also pass a function instead of a fixed value to .attr():
$('.priceinfo.col5').attr('data-price', function() {
var text = $(this).text();
return parseInt(text, 10); //drops the non-numeric characters at the end of the text
});
This is extremely useful when there are multiple elements in the jQuery set -- multiple elements with the classes priceinfo and col5.
If the value might sometimes have initial non-numeric characters, then you could use a regular expression to parse the text:
$('.priceinfo.col5').attr('data-price', function() {
var text = $(this).text();
var matches = /\d+/.exec(text);
if (!matches) {return '';}
return parseInt(matches[0], 10);
});