简体   繁体   English

跨浏览器jQuery-Firefox问题

[英]Cross-Browser jQuery - Firefox issue

This code here: 这段代码在这里:

jQuery(function($){
        var $button = $('#addrowbutton'),
            $row = $('.addrow').clone();
        $button.click(function(){
            $row.clone().insertBefore( $button );
        });
    });

Won't work on Firefox but works fine on Chrome & IE. 在Firefox上无法使用,但在Chrome&IE上可以正常使用。

This is the calling button: 这是调用按钮:

<input type="button" class=button id="addrowbutton" name="addrowbutton" value="Add Row" style="height: 2em;"/>

Any ideas guys? 有想法吗? Thanks in advance. 提前致谢。

I've put your code in jsfiddle and tested it in Firefox. 我已经将您的代码放在jsfiddle中,并在Firefox中对其进行了测试。 Works fine for me. 对我来说很好。

http://jsfiddle.net/nadjib/X48xB/ http://jsfiddle.net/nadjib/X48xB/

HTML: HTML:

<div class="addrow">Row</div>
<input type="button" class=button id="addrowbutton" name="addrowbutton" value="Add Row" style="height: 2em;" />

jQuery: jQuery的:

var $button = $('#addrowbutton'),
    $row = $('.addrow').clone();

$button.click(function () {
    $row.clone().insertBefore(this);
});

I'm using "this" instead of $button, because "this" is what you just clicked on (ie the button here). 我使用“ this”而不是$ button,因为“ this”就是您刚刚单击的内容(即此处的按钮)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM