Good day, I made a link in html
<a href="javascript:void(0);" onClick="next(1)" id="next"></a>
If i click on it nothing happens. Can't use href="#" and that also doesn't work. But If I call next(1) in console it does work.
Event-handler
specifiedinline
expects function to be underglobal-scope
function next(id) { alert(id); }
<a href="javascript:void(0);" onClick="next(1)" id="next">Element</a>
It is better to not use capital case and use just onclick
.
<a href="javascript:void(0);" onclick="next(1);" id="next"></a>
<script>
function next(value){
alert(value);
}
</script>
Function "next()" already exists in javascript so it can't be called. Renamed to nextone() works just fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.