Add class to element that has the id from array
<p>I have an array that contains values from a cookie, if one of those values matches the id of an h2 I want to add the class testing. This is the latest route I have attempted. Thanks</p>

<pre><code>jQuery.each(arr, function(index, value) {
    $("h2.#" + value).addClass("testing");
});
</code></pre>

<p>Full code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    var cookieName = $("body").attr("id");
    storedCookieName = $.cookie(cookieName);

    if (storedCookieName != null) {

        var cookieValues = storedCookieName;
        var arr = storedCookieName.split(',');
        alert( "the cookie values for this page are :" + arr);

        jQuery.each(arr, function(index, value) {
            $("#" + value).addClass("testing");
        });


    } else {
        var cookieValues = '';
        alert("I don't have a cookie for this page");
};

  //add id's to each drop down box trigger
$('h2.contentTrigger').attr('id', function(i, value) {
    return "dropDownTrigger" + (i+1);
});

//Hide (Collapse) the toggle containers on load
$(".toggle_content_container").hide(); 

//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("h2.contentTrigger").click(function(){
    $(this).toggleClass("active").next().slideToggle("fast");
    return false; //Prevent the browser jump to the link anchor
});


$("h2.contentTrigger").click(function(){

      //get class of clicked item to check if dropdown is active when clicked
    var triggerClass = $(this).attr("class");
      //get id of clicked dropdown
    var targetLink = $(this).attr("id");

    if ((triggerClass == 'contentTrigger noprint active') || (triggerClass == 'contentTrigger print active')) {
        cookieValues+=($(this).attr("id")+",");
        $.cookie(cookieName, cookieValues, { path: '/', expires: 10 });
        //alert("adding value" + cookieValues);    
    }else{
        cookieValues = cookieValues.replace(targetLink+",", "");
        $.cookie(cookieName, cookieValues, { path: '/', expires: 10 });    
        //alert("new value" + cookieValues);    
    };
});

});//end:$(document).ready
&lt;/script&gt;

&lt;/head&gt;
&lt;body id="&lt;CFOUTPUT&gt;#SMPPageVariables.PageMetaKeywords#&lt;/CFOUTPUT&gt;"&gt;
&lt;div id="container"&gt;
&lt;CFINCLUDE TEMPLATE="../libraryelements/AR_TwoDeepLeft_Navigation.element"&gt;
&lt;div id="content"&gt;
&lt;CFMODULE TEMPLATE="../../modules/mod_page_item_area_display.cfm" AreaID="108" PageID="#SMPPageVariables.PageID#"&gt;
&lt;CFMODULE TEMPLATE="../../modules/mod_page_item_area_display.cfm" AreaID="109" PageID="#SMPPageVariables.PageID#"&gt;
&lt;!--Sample of output    
&lt;div class="tab"&gt;
    &lt;h2 class="contentTrigger noprint"&gt;&lt;a&gt;What Is Important To Know&lt;/a&gt;&lt;/h2&gt;
    &lt;div class="toggle_content_container noprint"&gt;
        &lt;div class="block"&gt;
            &lt;h4&gt;Info&lt;/h4&gt;
            &lt;p&gt;Info:&lt;/p&gt;
            &lt;ul&gt;
                &lt;li&gt;Words&lt;/li&gt;
                &lt;li&gt;Words&lt;/li&gt;
            &lt;/ul&gt;
            &lt;h4&gt;Heading&lt;/h4&gt;
            &lt;p&gt;Paragraph&lt;/p&gt;
            &lt;p&gt;Paragraph&lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
--&gt;    
&lt;/div&gt;
&lt;div class="hidden"&gt;&lt;CFMODULE TEMPLATE="../../modules/mod_page_item_area_display.cfm" AreaID="110" PageID="#SMPPageVariables.PageID#"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
