-3

I am not being able to call the click function on the appended data. I have a html structure like below and items are added after slider move. After the items are added, I need to get the click event but at the moment its not working.

HTML

   <div id="sidebar-right">
        <div id="found-results">
            <div class="ui list found-result"></div>
        </div>
    </div>

JS

var showNearbySearchResult = function(result, popLat, popLong) {
    item = '';
    item = '<div class="item id_">' +
        '<div class="content">' +
        '<a class="header right-header">' + result.name_e + '</a>' +
        '<div class="description">' + result.amphoe_e + ' ' + result.province_e +'<i class="map marker icon"></i>'+'</div>' +
        '</div>' +
        '</div><div class="pop-geometry">'+popLat+', '+ popLong+'</div>' + '</div>';
    $(".ui.list.found-result").append(item);
}


$('.ui.list.found-result').on('click', '._id', function(e) {
    alert(2);
    console.log($(this).text());
});
S S
  • 1,443
  • 2
  • 12
  • 42

1 Answers1

-1

Please Try This Code:-

$('.ui.list.found-result').on('click', '.id_', function(e) {
    alert(2);
    console.log($(this).text());
});
iPraxa Inc
  • 548
  • 3
  • 6