Hello everyone,

I was looking for a code like to store iframe's id in javascript's variable inside different divs.

 <div id="player">

    <iframe id="SAR7KmiCHto"  width="560" height="315" src="http://www.youtube.com/embed/SAR7KmiCHto?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
    </div>

    <div id="player2">
    <iframe width="560" height="315" src="//www.youtube.com/embed/9P9JSgZwrjc" frameborder="0" allowfullscreen id="9P9JSgZwrjc"></iframe>
    </div>

In above code there are two div ids i.e player and player2. Now I want to store id of iframe from player div in javascript/jquery variable. Need some suggestions.

                            Thanks in advance.

As i understand , you can find iframe. hope this help you.

<script>
        $(document).ready(function(){
                var test=$('#player').find('iframe').attr('id');
                alert(test);
        });
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.