bonaca
bonaca

Reputation: 125

loaded iframe is not recognized

$( document ).ready(function() {
$('#somediv').load('chapter.php');
var a = $('#vplayer').width();
alert (a);
});

this is inside chapter.php:

<iframe class='viframe' id='vplayer' src='//www.youtube.com/embed/XotSjeW0uos?rel=0'></iframe>

Alert appears but result is NULL.

All others elements are measured correctly.

Upvotes: 0

Views: 66

Answers (1)

Abraham Hamidi
Abraham Hamidi

Reputation: 13829

You have to wait for it to load:

$( document ).ready(function() {
    $('#somediv').load('chapter.php', function()
    {
        var a = $('#vplayer').width();
        alert (a); 
    });
});

Upvotes: 1

Related Questions