-1

Check it out...

function listaHistorico() {

        dbase.transaction(function (tx){
            tx.executeSql("SELECT DISTINCT numero FROM CONTACTOS_OUT", [], function (tx, results){

                var len = results.rows.length;

                for (var i=0; i<len; i++){

                    $("#lista").append("<li><a class='contactoSMS' href=#SMSCONTOUT?telefone="+ results.rows.item(i).numero + 
                            "><img class='photo' width='64' height='64' src='img/Android_AMCL.png'><h4>" 
                    + results.rows.item(i).numero + "</h4></a></li>");
                }
            }, erroEx);
        });

    $(".contactoSMS").click(function (){

        alert("Work please");

    });
}

am trying hard but $(".contactoSMS").click doesn't work it is for a mobile app that am working...

one idea?

user2647038
  • 163
  • 6

3 Answers3

1
$('#lista').on('click', ".contactoSMS", function() {
    alert("Work please");
});

.on() is for jQuery version 1.7 and above. If you have an older version, use this:

$("#SomeId").live("click",function(){
    //do stuff;
});
Sasidharan
  • 3,676
  • 3
  • 19
  • 37
0

To make it work on dynamic content, use on with delegation :

$('#lista').on('click', ".contactoSMS", function() {
    alert("Work please");
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
0

Once try like this. You need write jquery click function with in the $(document).ready(function(){}); method.

$(document).ready(function(){

     $(".contactoSMS").click(function (){

                alert("Work please");

                       });
});
kalyani puvvada
  • 496
  • 4
  • 12