javascript - How to click on a map area only once? -
i'm creating medical assessment , there page can select body parts in pain. once click on body part, name of displayed below. problem display multiple times when clicked repeatedly. there way block click event repeating?
here sample.
http://jsfiddle.net/qpmxnv2g/6/
var map = document.getelementbyid("map"); map.addeventlistener("click", function (e) { callaction(e.target); }); map.one("click", function (e) { callaction(e.target); }); var body = []; document.getelementbyid("body").innerhtml = body; function callaction(area) { body.push(area.title); document.getelementbyid("body").value = body; } document.getelementbyid("clear").addeventlistener('click', function () { body.length = 0; document.getelementbyid("body").value = ''; });
change function this:-
function callaction(area) { if (body.indexof(area.title) !== -1) { return; } body.push(area.title); document.getelementbyid("body").value = body; }
Comments
Post a Comment