How do i set value attribute to a div tag?

Viewed 23076

I have 3 boxes, when i click on each box i want to alert the attribute value of each box.

https://jsfiddle.net/aedzgu9v/

<div class="box" value="box1"></div>
<div class="box" value="box2"></div>
<div class="box" value="box3"></div>

.box{
  height: 80px;
  width: 80px;
  border: 2px solid blue;
  margin: 5px;
}

$('.box').on('click', function(){
    var value = $(this).val();
  alert(value);
});
2 Answers
Related