这只是您的window.send_to_editor
功能:
imgurl = $( \'img\', html ).attr( \'src\' );
应该是
imgurl = $( \'img\', $( html ) ).attr( \'src\' );
因为你的
html
变量既不是有效的DOM元素,也不是jQuery元素。
Additional Note:如果您想在多个文本字段上使用Thickbox,我建议您存储和创建send_to_editor
功能:
var image_field,
store_send_to_editor = null,
new_send_to_editor = null;
jQuery( function( $ ) {
store_send_to_editor = window.send_to_editor;
new_send_to_editor = function(html) {
imgurl = $( \'img\', $( html ) ).attr( \'src\' );
image_field.val( imgurl );
tb_remove();
window.send_to_editor = store_send_to_editor;
};
$( document ).on( \'click\', \'input.select-img\', function( evt ) {
image_field = $( this ).siblings( \'.img\' );
check_flag = 1;
tb_show( \'\', \'media-upload.php?type=image&TB_iframe=true\' );
window.sent_to_editor = new_send_to_editor;
return false;
} );
} );