【问题标题】:add element to upload image添加元素以上传图片
【发布时间】:2013-02-26 02:54:25
【问题描述】:

我尝试添加文件底部以在 joomla 3.0 后端添加图像

为此,我使用 Jquery 的 append() 函数

<div class="control-group">
            <div class="control-label"><?php echo $this->form->getLabel('imagenes'); ?></div>
            <div class="controls1"><?php echo $this->form->getInput('imagenes'); ?>
                <input type="button" id="boton_append_1" value="Add Imagen" />
            </div>
        </div>

而我的jquery函数是这样的

<script type="text/javascript">
                jQuery.noConflict();
                jQuery(document).ready(function(){
                    jQuery('#boton_append_1').click(function() {
                        jQuery('.controls1').append(

                        );
                    });
                });
            </script>

但我不知道如何添加要添加的元素

任何想法

【问题讨论】:

  • to add a file bottom ...您的意思是:“添加文件按钮”
  • yes @roXOn 类似这样的 php echo $this->form->getInput('imagenes');生成输入 type="file" 底部
  • 你为什么不试试 jQuery('.controls1').append(');

标签: jquery joomla joomla2.5


【解决方案1】:

使用insertBefore()

官方文档http://api.jquery.com/insertBefore/

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function()
    {
        jQuery('#boton_append_1').click(function()
        {
            jQuery('<input type="file" />').insertBefore(jQuery(this));
        });
    });
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多