Botić Denis Botić Denis - 4 months ago 7
jQuery Question

Select everything except iframe by using $(this) and .not

I have wrote this code and it is working properly:


<div class="service-box">
<!--Services Title 1-->
<h3>WordPress installation</h3>
<!--Content for title 1-->
<div class="service-content">
<!--Your youtube service video iframe code-->
<iframe width="420" height="315" src="" frameborder="0" allowfullscreen></iframe>
<!--Your service description-->
<p>I am offering services like:</p>
<p>WordPress installation to your already purchased domain and hosting.</p>
<p>Also I am able to create subdomain and install wordpress on it.</p>
<p>If You need me to make a WP backup, I can do that for You.</p>
<p>In case that You need me to restore your website from my previously made backup I am here for You.</p>


$(document).on('click', '.service-box', function(){
$('#popupWindow #contentBox').html($(this).html()); //I will change this line
$('body').css('overflow', 'hidden');

Then I try to select everything except IFRAME tag like this:

$('#popupWindow #contentBox').html($(this).not($('iframe')).html());

or like this:

$('#popupWindow #contentBox').html($(this).not('iframe').html());

and it doesn't work.
I have also tried to use:not selector in all combinations like this:

$('#popupWindow #contentBox').html($(this:not).html());

Nothing is working. Is there anyone who knows the answer to this?


You want to remove the iframe from the html of the clicked element, not from the clicked element itself. so.... you'll have to clone it and remove it from the clone, then append it.

var clone = $(this).clone();
$('#popupWindow #contentBox').html(clone.contents());