0

を使用してコンテンツをロードするページがあります

$('#header').load('head.html')、しかし、head.html 内のリンクは、website.css が以前にロードされたか、別の理由で私の website.css を使用できません。

だから私はこれを考えまし$('a:hover').css('color','green');たが、成功しませんでした。

タグで解決できますが、やりたくありません。

アップデート:


base.html

<script> 
    $('#header').load('/restaurant{{ chosenRest }}.html'); //chosenRest=1,2..etc
</script>

<div id="accordion">
<div id="header" >   </div></div>

私はレストラン1.html、レストラン2.htmlのようなファイルを持っています


restaurant1.html

<a href="/Giorgio"> Giorgio's </a>   

ウェブサイト.css

a:hover {color:green};


base.html のようなものを追加する<style> a:hover {color:green; } </style>と機能しますが、そのようにしたくありません。

更新:最終的に解決

ここで何が機能したか:

base.css新しいクラスを追加しました

.restaurant:a:hover {
      color:green;
} 

restaurant1.html

<a href="/Giorgio" class="restaurant"> Giorgio's </a>  
4

2 に答える 2

0

おそらく、make時にCSS がロードされませんloadDOM ready負荷に追加するだけです。

<script> 
$(function(){
    $('#header').load('/restaurant{{ chosenRest }}.html'); //chosenRest=1,2..etc
});
</script>
于 2013-04-16T08:29:20.393 に答える