Replace on data attribute value - Javascript jQuery

Javascript examples for jQuery:Data Attribute

Description

Replace on data attribute value

Demo Code

ResultView the demo in separate window

<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>

Related Tutorials