javascript - document.location to first child <a> tag not working in ie6 & ie7 -


i have html code :

<ul id="mainlynav"> <li><a href="#">text1</a>     <ul class="subnavul">         <li>             <a href="a.php">link a</a>         </li>         <li>             <a href="b.php">link b</a>         </li>         <li>             <a href="b.php">link b</a>         </li>     </ul> </li>  <li><a href="#">text2</a>     <ul class="subnavul">         <li>             <a href="d.php">link d</a>         </li>         <li>             <a href="e.php">link e</a>         </li>         <li>             <a href="f.php">link f</a>         </li>     </ul> </li></ul> 

i want when user clicks on 1 of top level links (text1 or text2) , page go first child link (in case of text1 page should go "a.php" ) write script way :

<script type="text/javascript"> $(document).ready(function(){     $('#mainlynav a[href="#"]').click(function(){         var dom = $(this).siblings('.subnavul').first();         var dom2 = dom.children('li').first();         var dom3 = dom2.children('a').first();         document.location=dom3.attr('href');         return false;     }); }); </script> 

this whole proccess works fine in modern browsers in ie6 & 7 , it's not working!

what's problem?

thanks in advance.

your code :

$(document).ready(function(){     $('#mainlynav a[href="#"]').click(function(){         var url = $(this).next('.subnavul').find('a').first().attr('href');         if(url) {             document.location.href = url;             return false;         }     }); }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -