Reputation: 4686
I am Trying to do something when the content of a DIV changes to an "O", but it does not seem to work for me.
My code looks like below. Any Ideas on how I can solve this problem :
jQuery('.select2-chosen').bind('DOMSubtreeModified', function(event)
{
var newText = $(this).text();
alert(newText);
if($('.select2-chosen:contains("O")').length === 1)
{
alert(newText);
}
});
Upvotes: 1
Views: 74
Reputation: 67505
Why not just using change()
event since select-2
will triggers the standard DOM event, so try :
$('#SPECIFIC_ID').on('change', function() {
____^^^^^^^^^^^ //Don't forget to change the id with yours
var selected_text = $('option:selected', this).text();
if( selected_text == "O" ){
alert('the selected value is O');
}
})
Hope this helps.
Upvotes: 2