I want to ask how can i sum data-price from images onclick with jquery?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<body>
<img id="1" src="" data-price="5">
<img id ="2" src="" data-price="10">
<div id="sum"></div>
</body>
</html>
thanks in advance.
You can get data-price using
.data()
Try this:
DEMO
Target the ID of the images, and attach an event handler, then on click, get the data attribute with data()
If you somehow need to sum this up in the #sum element, you should ask specifically about that.
EDIT:
and now you did ?