title: Access an element outside of the target
body: <p>I'm using jQuery Cookie to store values from a clicked element (link element with a flag image as background), that once clicked, it will change the HTML in a different target location.</p>
  
  <p>For example, below I'm trying to target <code>a.flag</code>, and then set a cookie that targets <code>a.nturl</code>, then finds the first <code>img</code> tag within it and outputs the <code>src</code> of that image element:</p>
  
  <pre><code>$("a.flag").click(function(event) {
      location.reload();
         $.cookie("language_name", event.target.id, { path: "/" });
         $.cookie("flag_url", $("a.nturl").find("img").attr("src"), {path: "/" });       
  }); 
  </code></pre>
  
  <p>Then here's the function that retrieves cookies and outputs them in HTML:</p>
  
  <pre><code> $(function() {
                 var language_name = $.cookie("language_name");
                 var flag_url = $.cookie("flag_url");
                    if (language_name === "English"){ 
  
                    $("div.selected").html( "&lt;a onclick=\"return false;\" href=\"#\"&gt;&lt;span&gt;&lt;img src=\"" + flag_url + "\" alt=\"English\" height=\"16\" width=\"16\"&gt;&lt;/span&gt;" + language_name + "&lt;/a&gt;");  
  
                 }
  </code></pre>
  
  <p>For some reason, the <code>flag_url</code> cookie is not storing values properly - it's currently storing only the first <code>src</code> attribute from <code>a.nturl</code>.  </p>
  
  <p>The code below seems to work great when performing actions within the target itself using  <code>$(this)</code>:</p>
  
  <pre><code>$("a.nturl").click(function(event) {
     location.reload();
                 $.cookie("language_name", $(this).attr("title"), { path: "/" });
                 $.cookie("flag_url", $(this).find("img").attr("src"), {path: "/" });
  
              }); 
  </code></pre>