-2

iPhoneハイブリッドアプリを開発しています。その中で、Javascript を使用してリンクを挿入し、イベントで呼び出される関数を定義しonclickました。

リンク関数をクリックすると、必要なアクションが実行されますが、その後、アプリの本文のどこかをクリックすると、同じ関数が再度呼び出されます。

これは、アプリに存在する 2 つのリンクの両方で発生しています。

誰が何が間違っているのか分かりますか?

画像をリンクとして追加する関数を作成しました。コードを以下に示します。

// create a link for delete enquiry
var DelLink = document.createElement("a");

// setting the name of the link.
DelLink.setAttribute("name" , "DelButton"+pCurrentEnquiryID);

// image for the delete and its properties.
var DelImage = document.createElement("img");
DelImage.setAttribute("src","images/delete.png");
DelImage.setAttribute("height","30px");
DelImage.setAttribute("width","30px");

// append image to the link
DelLink.appendChild(DelImage);

//specifying onclick event of the link
DelLink.setAttribute("onclick","DeleteEnquiry(this)");
//DelLink.onclick = "DeleteEnquiry(this)";

return DelLink;
4

1 に答える 1