Javascript 在所有子输入JQuery上使用replaceWith
基本上在.show()上,我一直在尝试将所有输入转换为图像标记,img src等于原始输入值,如下所示:Javascript 在所有子输入JQuery上使用replaceWith,javascript,jquery,Javascript,Jquery,基本上在.show()上,我一直在尝试将所有输入转换为图像标记,img src等于原始输入值,如下所示: var currentPage = $('.three_paj_els:visible'); var nextPage = currentPage.next('.three_paj_els'); var the_parent_div_id = currentPage.attr('id'); nextPage.show(function() { $('div#' + t
var currentPage = $('.three_paj_els:visible');
var nextPage = currentPage.next('.three_paj_els');
var the_parent_div_id = currentPage.attr('id');
nextPage.show(function() {
$('div#' + the_parent_div_id + ':input').each(function() {
var the_image_SRC = $(this).val();
$(this).replaceWith('<img src="' + the_image_SRC + '" ')
})
})
var currentPage=$('.three_paj_els:visible');
var nextPage=currentPage.next('.three_paj_els');
var the_parent_div_id=currentPage.attr('id');
nextPage.show(函数(){
$('div#'+父项_div_id+':input')。每个(函数(){
var the_image_SRC=$(this.val();
$(this).replaceWith('
我已经做了几个小时了。我只想要那个特定div中显示要转换的那些
这是我一直在做的一把小提琴
单击下一步按钮时,
标记应转换为
标记,并且图像应显示
先谢谢你。
-SalcurrentPage
似乎没有ID。但您正在过度复杂化它-如果您有元素,您可以使用它在上执行jQuery函数。您不需要执行元素->ID->元素转换,因为这是毫无意义的
要查找子体,您需要在元素选择器和子体选择器之间留出一个空格,否则选择器将应用于元素本身。在您的情况下,您可以使用.find
此外,您还缺少图像的结束标记
//我猜您希望在新页面上替换为图像,而不是当前页面上的图像
//它被隐藏了
nextPage.find(':input')。每个(函数(){
var the_image_SRC=$(this.val();
$(此)。替换为(“”)
});
currentPage
似乎没有ID。但您正在过度复杂化它-如果您有元素,您可以使用它在上执行jQuery函数。您不需要执行元素->ID->元素转换,因为这是无意义的
要查找子体,您需要在元素选择器和子体选择器之间留出一个空格,否则选择器将应用于元素本身。在您的情况下,您可以使用.find
此外,您还缺少图像的结束标记
//我猜您希望在新页面上替换为图像,而不是当前页面上的图像
//它被隐藏了
nextPage.find(':input')。每个(函数(){
var the_image_SRC=$(this.val();
$(此)。替换为(“”)
});
我可以在两分钟内接受答案,该死的,这比我想象的要容易得多。我可以在两分钟内接受答案,该死的,这比我想象的要容易得多
// I guess you want to replace with images on the new page, not the one
// which gets hidden
nextPage.find(':input').each(function() {
var the_image_SRC = $(this).val();
$(this).replaceWith('<img src="' + the_image_SRC + '">')
});