I have to run some code only when a particular element in the DOM (img tag) exists, if not then I want to run some other code. Below is what I have till now.
Original Code:
ed.on('blur', function (e) {
var iFrame = $('iframe');
$("img[src*='blob']", iFrame.contents()).each(function (i) {
var originalUrl = $(this).prop('src');
var that = $(this);
// SOME CODE
);
});
Below is what I want
ed.on('blur', function (e) {
var iFrame = $('iframe');
******If ( img[src*='blob' exists in the iFrame )********
$("img[src*='blob']", iFrame.contents()).each(function (i) {
var originalUrl = $(this).prop('src');
var that = $(this);
// SOME CODE
);
}
else
{
// Do something else
}
});
So basically if I cannot find $("img[src*='blob']"
in the iframe I want to run some other code. Please guide me.