jquery不支持firefox

时间:2015-09-26 09:10:52

标签: jquery firefox

我正在开发一个预订系统。用于选择日期的日历在chrome中工作正常。但不是在Firefox中。它只是显示为一个普通的文本框。我错过了包含的任何jQuery吗?有没有更好的方法呢?

<script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready( function() 
{
    $('#ClickEventList li').click(function() { 
        $("#ccc").insertAtCaret($(this).text());
        return false
    });
    $('#ClickWordList li').click(function() { 
        $("#bbb").insertAtCaret($(this).text());
        return false
    });
    $("#DragWordList li").draggable({helper: 'clone'});
    $(".txtDropTarget").droppable({
        accept: "#DragWordList li",
        drop: function(ev, ui) {
            $(this).insertAtCaret(ui.draggable.text());
        }
    });
});

$.fn.insertAtCaret = function (myValue) {
    return this.each(function(){
        //IE support
        if (document.selection) {
            this.focus();
            sel = document.selection.createRange();
            sel.text = myValue;
            this.focus();
        }
        //MOZILLA / NETSCAPE support
        else if (this.selectionStart || this.selectionStart == '0') {
            var startPos = this.selectionStart;
            var endPos = this.selectionEnd;
            var scrollTop = this.scrollTop;
            this.value = this.value.substring(0, startPos)+ myValue+ this.value.substring(endPos,this.value.length);
            this.focus();
            this.selectionStart = startPos + myValue.length;
            this.selectionEnd = startPos + myValue.length;
            this.scrollTop = scrollTop;
        } else {
            this.value += myValue;
            this.focus();
        }
    });
};
 </script>

你知道为什么会这样吗?

0 个答案:

没有答案