ImageMapster (JavaScript)- “onClick” function wont work properly

拈花ヽ惹草 提交于 2019-12-08 03:15:36

问题


Iam having a problem with a function on ImageMapster. The whole Project works except this little problem:

$('#STADION1').mapster({ 
  mapKey: 'href',
  fillColor:'999999',
  stroke: true,
  strokeWidth:2,
  strokeColor:'3355aa',
  onClick: function(data){
    $test = "";
    $test = $('area').mapster('get');
    document.getElementById('awesome').innerHTML = $test ;
  }
});

So, I have 1000 lines "coordinates" who are all working ("href" is set to '#Number'). What i want to do: if you click on a coordinate, the special "href" value will be shown on a paragraph (with id 'awesome') on my site. The basic script works but there is a tiny mistake in it. If i click on the "first" coordinate nothing will appear in my paragraph. If i click on the "second" coordinate the value of "href" from the first coordinate will appear ... and so on. The latest "click" wont apprea in my paragraph and i dont know why.

To test if my imagemap works, I made a button with id="getAreas". This button got his own "click-funtction". If the Button is clicked, the paragraph (i use on the upper script, too) wil show the current "marked" coordinates. this works perfect. But i want to do it immediatly "onClick" like i describedon the upper side.

$('#getAreas').bind('click',function() {
$test = $('#STADION1').mapster('get');
document.getElementById('awesome').innerHTML = $test;
});

Can you guys help me <3. I dont know how to solve this problem

tl;dr: have a script where i want to show(the value of "href=" the current clicked "areas" of my imagemap. if i use "onClick" it works, but the "latest" area wont give his href-information. If i use the "Button-Script" it works perfect. But i wont use a button. pls help :)

来源:https://stackoverflow.com/questions/35088805/imagemapster-javascript-onclick-function-wont-work-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!