开发者

What should be the correct javascript syntax in this case?

I have a code that is a mix of HTML and js. I cannot get it correct.

location.description开发者_JS百科 + '<br><a href="javascript:void(0);" onclick="showStreet;">ShowStreet </a><br>'+ location.lat + '<br> + location.lng

Can anyone help me with it?


You have two problems in that:

  • You were missing ' after location.lat + '<br>
  • You were not suffixing the function showStreet with ()

Try this:

location.description + '<br><a href="javascript:void(0);" onclick="showStreet();">ShowStreet </a><br>'+ location.lat + '<br>' + location.lng

Note: You might want to add the return keyword for your function depending on whether you want to cancel it at some point.


Did you mean onclick="showStreet()" (instead of onclick="showStreet;")? From your question, it's unclear what the problem is.


location.description + '<br><a href="javascript:void(0);" onclick="showStreet();">ShowStreet </a><br>'+ location.lat + '<br>' + location.lng

You have to call a function inside onclick and there you were missing parenthesis. And also a single quote after the last <br>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜