jQuery function only inside a specific div ID

Posted by user412481 on Stack Overflow See other posts from Stack Overflow or by user412481
Published on 2012-04-10T23:14:51Z Indexed on 2012/04/10 23:29 UTC
Read the original article Hit count: 183

Filed under:
|

I have the following function that I only want to run inside a specific div with the id of imgWrapper.
I have tried a few things with parent but I cannot seem to figure this out.

 <script type="text/javascript" language="javascript">
    $(document).ready(
        function () {
            $("img").each(function () {
                var src = $(this).attr("src");
                if (src.substring(0, 1) == "/")
                    $(this).attr("src", "http://serverName.com/" + src.substring(1))
            });

        }
     ); 
 </script> 

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ASP.NET