2011-01-31 69 views
1

我尝试将链接样式化为JQuery UI按钮时出现了一个奇怪的问题。它在Chrome中显示为按钮,在Firefox和IE8中显示为链接。JQuery UI标签不作为Firefox和IE中的按钮样式

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <script type="text/javascript" src="script/jquery-1.4.2.js"></script> 
    <script type="text/javascript" src="script/jquery-ui-1.8.9.custom.min.js"></script> 
    <link rel="stylesheet" type="test/css" href="stylesheet/jquery-ui-1.8.9.custom.css"> 
    <link rel="stylesheet" type="text/css" href="stylesheet/styles.css"> 
    <script type="text/javascript"> 
     $(document).ready(function(){ 
      $("a").button(); 
     }); 
    </script> 
    <title>Introduction</title> 
</head> 
<body class="indexbody"> 
    <div class="indexwrapper"> 
     <div id="introduction">   
      <div class="btn"> 
       <a href="test.html" >link</a> 
      </div> 
     </div> 
    </div> 
</body> 
</html> 
+0

Firebug有什么结果?你看到的UI值设置类属性?你试过什么了?在汤姆克鲁斯的名言中,“帮助我帮助你”。 – jmort253 2011-01-31 03:53:52

+0

Firefox:class =“ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only”Chrome:class =“ui-button”ui-widget“ui-state-default”“ui-corner” -all ui-button-text-only“ 生成的HTML在Firefox和Chrome中完全相同。在IE中没有应用ui-类。 – 2011-01-31 03:56:33

+0

在Chrome中,我看到一个绿色按钮(如预期的那样)。在Firefox和IE中我看到一个链接。 – 2011-01-31 04:05:20

回答

3

它看起来像是很容易错过你的CSS链接元素中的错字。 type属性应该是text/css,而不是test/css

xs彼此如此接近。

<link rel="stylesheet" type="text/css" 
    href="stylesheet/jquery-ui-1.8.9.custom.css"> 

在Chrome改编后,其他浏览器对其语法更加严格。 Chrome遵循Robustness Principle

最后,加载CSS或JavaScript的顺序似乎没有关系。链接标记可以在脚本元素之前或之后出现。

1

CSS首先包含JS,这应该可以解决您的问题。

<link rel="stylesheet" type="test/css" href="stylesheet/jquery-ui-1.8.9.custom.css"> 
<link rel="stylesheet" type="text/css" href="stylesheet/styles.css"> 
<script type="text/javascript" src="script/jquery-1.4.2.js"></script> 
<script type="text/javascript" src="script/jquery-ui-1.8.9.custom.min.js"></script>