Javascript examples for jQuery:Data Attribute
Replace on data attribute value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w . j ava 2s. c o m $('#output').text(function(_,txt) { return $(this).attr('data-value').replace('-',''); }); }); </script> </head> <body> <div id="output" data-value="-17"></div> </body> </html>