我刚刚发布了一个类似的问题,以发现这不是我所需要的。我很抱歉。
这是我正在使用的代码:
jQuery(document).ready(function($) {
$('.upload_button').click(function() {
targetfield = $(this).prev('.logo_url');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
window.send_to_editor = function(html) {
imgurl = $('img',html).attr('src');
jQuery(targetfield).val(imgurl);
tb_remove();
$('.upload_preview img').attr('src',imgurl); // THIS IS WHERE I'M HAVING PROBLEMS
$('#submit_options_form').trigger('click');
};
return false;
});
});
我对 jQuery 不是最好的,而且对某些东西还是很陌生。我需要在预览类中填充 img 标记的 url,但仅限于获取 url 的那个。我现在拥有的将填充具有该类的每个图像标签。任何帮助是极大的赞赏。
我需要它来填充它,就像填充输入字段一样。
编辑
这是一些示例 HTML。我在一个页面上使用多个这些。
<li class="slide">
<input class="logo_url" name="theme_wptuts_options[logo]" value="src[]" />
<input class="upload_button" type="button" class="button" value="<?php _e( 'Upload Logo' ); ?>" />
<div class="upload_preview" style="min-height: 100px;">
<img style="max-width:100%;" src="src[]" />
</div>
<button class="remove_slide button-secondary">Remove This Slide</button>
</li>