jquery set data attribute

Jquery Set custom data attribute value

index.html

<!DOCTYPE html>
<html>
<head>
    <title>Jquery Set custom data attribute value | Jquery Get custom data attribute value - Pakainfo.com</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<b>jquery set data attribute</b>  
<div id="example1">Working with me</div>
<button class="set-attr">Set Attribute</button>
<button class="get-attr">Get Attribute</button>
      
<script type="text/javascript">
   
$(".set-attr").click(function(){
    $("#example1").attr('custom-name', 'Pakainfo.com');
});
  
$(".get-attr").click(function(){
    var name = $("#example1").attr('custom-name');
    alert(name);
});
  
</script>
  
</body>
</html>