title: jQuery $this clicked element
body: <p>I have the following script that sends an image URL to an input field on click (from a modal window). I am also sending that same url, <code>imgurl</code> to a <code>&lt;div class="preview-image&gt;</code> to show it on insertion.</p>
  
  <pre><code>var BusiPress_Configuration = {
      init : function() {
          this.files();
      },
  
      files : function() {
          if ( $( '.busipress_upload_image_button' ).length &gt; 0 ) {
              window.formfield = '';
  
              $('.busipress_upload_image_button').on('click', function(e) {
                  e.preventDefault();
                  window.formfield = $(this).parent().prev();
                  window.tbframe_interval = setInterval(function() {
                      jQuery('#TB_iframeContent').contents().find('.savesend .button').val(busipress_vars.use_this_file).end().find('#insert-gallery, .wp-post-thumbnail').hide();
                  }, 2000);
              if (busipress_vars.post_id != null ) {
                  var post_id = 'post_id=' + busipress_vars.post_id + '&amp;';
              }
                  tb_show(busipress_vars.add_new_file, 'media-upload.php?' + post_id +'TB_iframe=true');
              });
  
              window.original_send_to_editor = window.send_to_editor;
              window.send_to_editor = function (html) {
                  if (window.formfield) {
                      imgurl = $('a', '&lt;div&gt;' + html + '&lt;/div&gt;').attr('href');
                      window.formfield.val(imgurl);
                      window.clearInterval(window.tbframe_interval);
                      tb_remove();
                      $('.preview-image img').attr('src',imgurl);
                  } else {
                      window.original_send_to_editor(html);
                  }
                  window.formfield = '';
                  window.imagefield = false;
              }
          }
      }
  }
  
  BusiPress_Configuration.init();
  </code></pre>
  
  <p>Sending the image URL to the editor and the div are working fine, but it is doing it for every instance of that div on the page. I've been playing around with <code>$(this)</code> and <code>closest()</code> to see if I could localize the insertion to the specific div near the input, but haven't had any luck. Any help would be greatly appreciated. Thanks!</p>
  
  <h1>Default markup</h1>
  
  <pre><code>  &lt;table class="form-table"&gt;
      &lt;tbody&gt;
        &lt;tr valign="top"&gt;
          &lt;th scope="row"&gt;Default Map Icon&lt;/th&gt;
  
          &lt;td&gt;
            &lt;input type="text" class="-text busipress_upload_field" id=
            "busipress_settings_map[default_map_icon]" name=
            "busipress_settings_map[default_map_icon]" value=
            "http://localhost/jhtwp/wp-content/plugins/busipress/img/red-dot.png" /&gt;&lt;span&gt;&amp;nbsp;&lt;input type="button"
            class="busipress_upload_image_button button-secondary" value=
            "Upload File" /&gt;&lt;/span&gt; &lt;label for=
            "busipress_settings_map[default_map_icon]"&gt;Choose the default map icon (if
            individual business type icon is not set&lt;/label&gt;
  
            &lt;div class="preview-image" style="padding-top:10px;"&gt;&lt;img src=
            "http://localhost/jhtwp/wp-content/plugins/busipress/img/red-dot.png" /&gt;&lt;/div&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
  
        &lt;tr valign="top"&gt;
          &lt;th scope="row"&gt;Active Map Icon&lt;/th&gt;
  
          &lt;td&gt;
            &lt;input type="text" class="-text busipress_upload_field" id=
            "busipress_settings_map[active_map_icon]" name=
            "busipress_settings_map[active_map_icon]" value=
            "http://localhost/jhtwp/wp-content/plugins/busipress/img/blue-dot.png" /&gt;&lt;span&gt;&amp;nbsp;&lt;input type="button"
            class="busipress_upload_image_button button-secondary" value=
            "Upload File" /&gt;&lt;/span&gt; &lt;label for=
            "busipress_settings_map[active_map_icon]"&gt;Choose the active map icon (if
            individual business type icon is not set&lt;/label&gt;
  
            &lt;div class="preview-image" style="padding-top:10px;"&gt;&lt;img src=
            "http://localhost/jhtwp/wp-content/plugins/busipress/img/blue-dot.png" /&gt;&lt;/div&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  </code></pre>