我需要在可编辑的iframe中选择imgs进行一些操作。我可以做到这一点与所有图像(这里是代码,例如) $(iframe).contents().find('img').attr('alt', 'new alt')
但我只需要img WITHIN用户选择。请帮帮我。由于jquery如何操作可编辑iframe中的用户选择中的img属性
//inserted within your selection method
$(iframe).contents().find('img').removeClass('selectionClass');
//this removes all previously selected images
//unless you have a deselection method in which case you don't need this,
//you would need to add $(this).removeClass('selectionClass') to the deselection
$(this).addClass('selectionClass');
//adds it to currently selected images
然后选择类添加到用户的选择图像
嗯,这段代码适用于iframe中的所有图片。例如,用户选择带有文本和图像的可编辑iframe内容的片段 - 并且需要使用alt属性alt ='Hello,Im用户选择中的图像进行所有图像的选择。 - 我认为你的代码不能正常工作 – 2012-07-30 12:29:06
如何选择图像? – CKKiller 2012-07-30 13:16:00
图像可以在选定的文本块内,因此需要在用户选择中找到它并使用属性进行一些操作 – 2012-07-30 13:29:49