Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用JQuery在chrome上动态创建文本类型输入区域_Html_Jquery - Fatal编程技术网

Html 使用JQuery在chrome上动态创建文本类型输入区域

Html 使用JQuery在chrome上动态创建文本类型输入区域,html,jquery,Html,Jquery,这是我的代码,它在firefox中运行良好,但在chrome中却不行。当我调试页面时,会创建文本区域,但它不在chromes屏幕上。当我使用较低版本的jquery时,我遇到了一个webkit错误,建议我开始使用这个版本。它解决了错误消息,但没有解决实际问题 <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></sc

这是我的代码,它在firefox中运行良好,但在chrome中却不行。当我调试页面时,会创建文本区域,但它不在chromes屏幕上。当我使用较低版本的jquery时,我遇到了一个webkit错误,建议我开始使用这个版本。它解决了错误消息,但没有解决实际问题

<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
    <script type="text/javascript">
        function loadAddressXML(address) {
            var file = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + address + "&sensor=true";
            if(window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else {// code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    xml2 = xmlhttp.responseText;
                    alert(xml);
                }
            }
            xmlhttp.open("GET", file, false);
            xmlhttp.send();
        }

        $(document).ready(function(){
            $("#searchButton").click(function(){
                var newTextBoxDiv = $(document.createElement('div'))
                                    .attr("id", 'TextBoxDiv');
                newTextBoxDiv.html('<label>Enter Address: </label> ');
                newTextBoxDiv.html('<input type = "text" id="searchBar" size="35" value="dfsfsdfsfsf"/>');
                newTextBoxDiv.appendTo("body");
                $("#searchButton").remove();                                                
            });

        });
    </script>
</head>
<body>
    <input id="searchButton" type="button" value="Search Address"/>
</body>

函数loadAddressXML(地址){
变量文件=”http://maps.googleapis.com/maps/api/geocode/xml?address=“+地址+”&传感器=真”;
if(window.XMLHttpRequest){//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}else{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
xml2=xmlhttp.responseText;
警报(xml);
}
}
open(“GET”,file,false);
xmlhttp.send();
}
$(文档).ready(函数(){
$(“#搜索按钮”)。单击(函数(){
var newTextBoxDiv=$(document.createElement('div'))
.attr(“id”,“TextBoxDiv”);
html('输入地址:');
newTextBoxDiv.html(“”);
newTextBoxDiv.附录(“正文”);
$(“#搜索按钮”).remove();
});
});

问题是什么?意思是,这段代码应该做什么,它在做什么?当然要提供更多的细节。我刚刚制作了一个JSFIDLE,它按照您所说的那样工作:问题是如何解决这个问题。这是什么,我不能添加文本框,假设与此代码虽然它在firefox上工作,它不谷歌为什么?引用Erogol:“问题是如何解决这个问题。”不是开玩笑。但你在最初的帖子中没有描述任何实质内容。请查看并相应编辑: