I'm trying to apply a CSS class to an element of my DOM HTML. Here's my HTML code : an i
element inserted into a div
.
<div class="delete delete_next" data-url="{{call.url}}" data-def="{{ call.person._id }}" data-annonce="{{ annonce._id }}"><i class="fa fa-check"></i></div>
In Javascript I'm doing an Ajax Query. if the json data.url I'm getting equals the url variable that I have in JS. I'm trying to add a css class to the element next to the div.
$('.delete_next').each(function(){
var diff = $(this).data('def');
var annonce = $(this).data('annonce');
var url = $(this).data('url');
$.ajax({
url: 'index.php',
data: {
module: 'admin',
action: 'call_url',
diff: diff,
ann: annonce
},
dataType : 'json',
success : function(data){
if(data.url == url){
$(this).next().addClass('valdiate');
}
}
})
});
And finally here's the CSS class :
<style>
.valdiate{
color: #327334;
opacity: 1;
}
</style>
So what's wrong in my code.
Thanks