Невозможно заставить работать скрипт jQuery в Firefox - PullRequest
0 голосов
/ 27 апреля 2009

У меня есть скрипт на моей домашней странице

$(function () { // same as $(document).ready(function () { })
  // assuming we have the open class set on the H2 when the HTML is delivered
  $('li.drawer h2:not(.open)').next().hide();

  $('h2.drawer-handle').click(function () {
    // find the open drawer, remove the class, move to the UL following it and hide it
    $('h2.open').removeClass('open').next().hide();

    // add the open class to this H2, move to the next element (the UL) and show it
    $(this).addClass('open').next().show();
  });
});

Работает в Safari, но не в Firefox 3.08 / 3.1 beta3.

Как вы можете заставить работать вышеупомянутый скрипт jQuery в Firefox?

[править]

Первые строки моего index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"/>
<link href="template.css" type="text/css" rel="stylesheet"/>
<title>Abc</title>

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

<script type="text/javascript"> 

! - - - - Above Code is at Here - - - - - 

</script>

</head>

Тело index.html

<body>
<div class="mainbody">

<h1 class="myheader">Test</h1>
<p>Test</p>

<ul class="drawers">

   <li class="drawer">
      <h2 class="drawer-handle open">Contact info</h2>
      <ul>

         <li>name
         </li>

         <li>
            <div class="">aaa
            </div>
         </li>
      </ul>
   </li>

   <li class="drawer">
      <h2 class="drawer-handle">Unpublished</h2>
      <ul>
         <li class="italic">
            <i>A</i> (2009).
         </li>
         <li class="italic">
            <i>aaa</i> (2008).
         </li>
      </ul>
   </li>     

   <li class="drawer">
      <h2 class="drawer-handle">Recent projects</h2>
      <ul>
         <li class="italic">
            Websites
         </li>

         <li class="italic">
            Search
            <form action="http://www.google.com/cse" id="cse-search-box">
            <div>
               <input type="hidden" name="cx" value="8834479:1qd7hky6khe" />
               <input type="hidden" name="ie" value="UTF-8" />
               <input type="text" name="q" size="31" />
               <input type="submit" name="sa" value="Search" />
            </div>
            </form>
            <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
         </li>

      </ul>
   </li>     

</ul>


</div>

</body>
</html>

Ответы [ 4 ]

2 голосов
/ 27 апреля 2009

Я предполагаю, что у вас неверный HTML, что приводит к неправильной структуре DOM в Firefox. Но это трудно сказать, не глядя на ваш код.

2 голосов
/ 27 апреля 2009

у меня работает в Firefox 3.0.9

Что именно не работает?

1 голос
/ 28 апреля 2009

Я получил код для работы в Firefox, заменив следующий

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

до

<script type="text/javascript" src="jquery.js"></script>  
1 голос
/ 27 апреля 2009

Почему ваши метки в селекторах jquery в верхнем регистре? По вашему типу документа вы используете XHTML, и все теги должны быть строчными. Не уверен, что это будет иметь значение, но вы должны изменить H2 => h2 и т. Д.

...