jQuery Selectors: Attribute attr begins with a value

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

Here we use jQuery selectors to select an <img> elements whose src attribute starts with http.

The image is sized to a height of 200px through a jQuery selector.

The syntax is $(‘[attr^=value]’).

<!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^='http']").css('height', '200px');


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

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



Series Navigation<< jQuery Selectors: Select all elements that match a substring
jQuery Selectors: Using meta or special characters >>

Leave a comment

Leave a Reply