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
Javascript CSS for JS按钮在本地计算机上工作,但在服务器上不工作_Javascript_Jquery_Html_Css_Internet Explorer 8 - Fatal编程技术网

Javascript CSS for JS按钮在本地计算机上工作,但在服务器上不工作

Javascript CSS for JS按钮在本地计算机上工作,但在服务器上不工作,javascript,jquery,html,css,internet-explorer-8,Javascript,Jquery,Html,Css,Internet Explorer 8,我正在使用一系列JS打开/关闭按钮。在本地机器上测试非常完美,但上传时只在非IE浏览器上运行(令人惊讶) 路径都是正确的,经过三次检查。另外,它们在非IE浏览器中工作 按钮的CSS .bluebutton{ -moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px; -moz-box-shadow:0 1px 1px rgba(0, 0, 0, 0.2);-webkit-box-shadow:0 1px 1px rgba

我正在使用一系列JS打开/关闭按钮。在本地机器上测试非常完美,但上传时只在非IE浏览器上运行(令人惊讶)

路径都是正确的,经过三次检查。另外,它们在非IE浏览器中工作

按钮的CSS

.bluebutton{
-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;
-moz-box-shadow:0 1px 1px rgba(0, 0, 0, 0.2);-webkit-box-shadow:0 1px 1px rgba(0, 0, 0, 0.2);box-shadow:0 1px 1px rgba(0, 0, 0, 0.2);
background-color:#e0e0e0;
border:0;
color:#333;
cursor:pointer;
font-family:arial,helvetica,sans-serif;
margin:0;padding:5px;
text-decoration:none;text-align:center;font-size:15px;font-weight:400; 
border-bottom:2px inset #cccccc;
position:relative;display:block;
width:100%;
}
加价

<script src="jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function(){   
$('.blue').hide().before('<a href="#" id="toggle-blue" class="bluebutton">Primary Text <br> Subtext</a>');
 $('a#toggle-blue').click(function() {
    $('.blue').slideToggle(1000);
    return false;
 });
 });
 </script>

<div class="blue">Text</div>

$(文档).ready(函数(){
$('.blue').hide().before('');
$('a#切换蓝色')。单击(函数(){
$('.blue')。滑动切换(1000);
返回false;
});
});
正文
如果我手动设置每个按钮的格式,这些按钮确实可以工作。问题是我正在创建一个非常大的手风琴风格的菜单,有4层按钮,手动格式化这些按钮会消耗掉200kb。见下文

<script type="text/javascript">
$(document).ready(function(){   
$('.blue').hide().before('<a href="#" id="toggle-blue" class="button" style="width:100%;display:block;height:40px;color:#e0e0e0;font-weight:bold;font-family:arial,helvetica,sans-serif;font-size:18px;text-align:center;padding:5px 0px;margin:0;">Primary text <br> Subtext</a>');
$('a#toggle-blue').click(function() {
    $('.blue').slideToggle(1000);
    return false;
});
 });
 </script>

$(文档).ready(函数(){
$('.blue').hide().before('');
$('a#切换蓝色')。单击(函数(){
$('.blue')。滑动切换(1000);
返回false;
});
});

看起来我的问题是IE在兼容模式下渲染东西。添加:
到我的头上
我确实帮了忙。感谢大家的评论和建议。

它在IE中起什么作用?它只创建一行文本,就好像是带有蓝色背景的。JS仍然可以工作,我可以打开和关闭按钮,但它缺少块形状和文本格式。当在实际URL上通过HTTP查看页面时,IE可能会触发兼容性视图。打开开发工具(F12)并检查IE是否使用兼容视图或旧模式。这似乎确实有一些影响。首先读取IE9,但将模式切换到IE8和IE9。两者都刷新了页面以正常工作。你认为这能解决问题吗?您是否尝试过创建元素而不是将其作为字符串传递
.before($('').addClass(“button”).attr('href','#').attr('id','toggle blue').text('subtext'))
-IE有一个很好的习惯,即在某些情况下,如果元素作为字符串添加,则不呈现它们。