I have one div section with dynamic data and static button.
HTML:
<div class="main">
<div class="subSection">
<section>
<button type="button" class="btn btn-danger hideEquipmentDetails" onclick="clickme()"><i class="fa fa-times" ></i></button>
</section>
</div>
</div>
SCRIPT:
<script>
details()
function details(){
var details= response.data.filters;
$.each(details,function(i,value){
$('.subSection').append('<section><label>Speed</label><label>'+value.speed+'</label></section>');
});
}
function clickme(){
$('.main').hide();
}
</script>
Here click me function works fine when button is clicked.
Am refreshing the method for every 5 seconds.so I need to clear the previous html content of .subSection
when method is loaded.So I have decided to append a button dynamically.
I changed my code like this:
HTML:
<div class="main">
<div class="subSection">
</div>
</div>
SCRIPT:
<script>
details()
function details(){
$('subSection').html('');
var details= response.data.filters;
$.each(details,function(i,value){
$('.subSection').append('<section><label>Speed</label><label>'+value.speed+'</label></section>');
});
$('.subSection').append('<section><button type="button" class="btn
btn-danger hideEquipmentDetails" onclick="clickme()"><i class="fa fa-
times" ></i></button>
</section>')
}
function clickme(){
$('.main').hide();
}
</script>
But clickme
method is not triggered now.I tried using .click
also.Is anything wrong in my code?