[英]Javascript event listener works in browser, not in phonegap?
[英]Hyperlink click event not working with phonegap but works on browser
以下是我的代碼的一部分,如果在瀏覽器上運行,則可以正常運行,但如果與phonegap一起使用並在設備上運行,則不會觸發功能“ incrementClickCounter”
<div class="newsheading">
<h1><a id="newsTitle" data-bind="text:title,click:function () {
incrementClickCounter(title, content, publish_date, $index());}"></a></h1>
</div>
function incrementClickCounter(title=null, content=null, date=null, index=null){
alert('hello');
}
我也嘗試調用按鈕單擊事件。 但沒有運氣。 我是否缺少js文件之類的東西?
您的函數應位於<head>
,如下所示:
<head>
<script>
function incrementClickCounter(){
alert('hello');
}
</script>
</head>
順便說一句,屬性有什么用? 您沒有訪問它們,因此刪除它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.