我刚刚发布了一个类似的问题,以找出它并不完全是我需要的。我很抱歉。使用jQuery选择当前div的第一张图片
这是我与工作代码:
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的那个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>
这样一个简单的解决方案...太糟糕了,很难找到它!好工作人! – VIDesignz