Uncaught TypeError when trying to alter image states
<p>I am trying to write a piece of code that when a button is clicked, it checks through a list of images, checks if it has an id of 'video' and if it does then display an overlay and remove the player that is there.</p>

<p>I keep getting this error:</p>

<pre><code>Uncaught TypeError: Cannot call method 'indexOf' of undefined
</code></pre>

<p>Here is the code:</p>

<pre><code>$("#actions .btn").click(function(){
       $('.span img').each(function(){
            if($(this).attr('id').indexOf('video') != -1){
                var spanid = $(this).attr('id').replace(/video/, '');
                $(this).removeClass('hideicon');
                $('#mediaplayer' + spanid + '_wrapper').remove();
            }
        });
});
</code></pre>
