jQuery Selectors: Using meta or special characters

This entry is part 10 of 33 in the series jQuery Selectors

In the previous example, the image src url starts with http://codecrawl.com.

The 2 forward slashes // are meta characters.

If the image source has the below url, we would need to use escape character with 2 backslashes \\ in the selector.

<img src=’//codecrawl.com/code/images/ushuaia.jpg’>

The selector would need to be established as $(“img[src^=’\\/\\/code’]”).

<!DOCTYPE html>
<head lang='en'>
    <meta charset='UTF-8'>
    <script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
        $(function () {
            $("img[src^='\\/\\/code']").css('height', '200px');


<p>Southernmost city in the world.</p>

<img src='//codecrawl.com/code/images/ushuaia.jpg'>



Series Navigation<< jQuery Selectors: Attribute attr begins with a value
jQuery Selectors: Attribute attr not equal to a value >>

Leave a comment

Leave a Reply