I have several pages that has the following mark-up in it, but the value of the datetime attribute is on each page different.

<a class="index" href="#">

    <time datetime="2015-W01">

        <strong>week</strong>
        <strong>01</strong>
        <strong>2015</strong>

    </time>

</a>

On each page I include with PHP at the bottom a page with the following mark-up:

<ul class="weeks">

    <li>

        <a class="ajax" href="<?php echo _LINK_PATH;?>tracks-sets-03-2015">

            <time datetime="2015-W03">

                <strong>week</strong>
                <strong>03</strong>
                <strong>2015</strong>

            </time>

            <ol>

                <li>artist 01</li>
                <li>artist 02</li>
                <li>artist 03</li>
                <li>artist 04</li>
                <li>artist 05</li>

            </ol>

        </a>

    </li>
    <li>

        <a class="ajax" href="<?php echo _LINK_PATH;?>tracks-sets-02-2015">

            <time datetime="2015-W02">

                <strong>week</strong>
                <strong>02</strong>
                <strong>2015</strong>

            </time>

            <ol>

                <li>Hill Classics</li>
                <li>Colman Brothers</li>
                <li>Vicktor Taiwò</li>
                <li>Leftside Wobble</li>
                <li>Mo Kolours</li>

            </ol>

        </a>

    </li>
    <li>

        <a class="ajax" href="<?php echo _LINK_PATH;?>tracks-sets-01-2015">

            <time datetime="2015-W01">

                <strong>week</strong>
                <strong>01</strong>
                <strong>2015</strong>

            </time>

            <ol>

                <li>artist 01</li>
                <li>artist 02</li>
                <li>artist 03</li>
                <li>artist 04</li>
                <li>artist 05</li>

            </ol>

        </a>

    </li>

</ul>

As the titel stated I want to look for the time element with a matching date-time attribute value in ul.weeks and then do something. That 'something' I know how to do (I guess :) ), but searching for the matching attribute value, I don't know yet.
Can I even store the date-time attribute value of the time element (in a.index) in a variable, so that I can use that to look for a match in ul.weeks? Or do I have to use data attributes instead.

Well, let me answer my own question, because I figured it out :)
This will do the trick:

var $dt = $('.index').find('time').attr('datetime');

$('.weeks').find('time').filter(function(){ 
    return $(this).attr('datetime').match($dt) 
});
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.