I'm using data-attribute and suppose I have a value: world is best (20052) and i want it as world is best - 20052
var a = $('[some-data-attribute]').text().replace(/\(|\)/g, '-');
This gives me: world is best -20052-.
However, I'd like it to get world is best - 20052.
.text()doesn't get the value of the data attribute, it gets the text content of the element. Use.data()too get the value of the attribute.