jquery problem internet explorer 9 and 7
$(document).ready(function(){
$("#yanMenu ul").hide();
$("div#button").click(function(){
$(this).next().slideToggle("normal");
});
});
<div id="yanMenu">
<div id="button"><h5>Kategori 1</h5></div>
<ul>
<li><a href="#">Secenek 1</a></li>
<li><a href="#">Secenek 2</a></li>
<li><a href="#">Secenek 3</a></li>
<li><a href="#">Secenek 4</a></li>
</ul>
</div>
<!-- This code it doesnt work!-->
<div id="yanMenu">
<div id="button"><h5>Kategori 1</h5></div>
<ul>
<li><a href="#">Secenek 1</a></li>
<li><a href="#">Secenek 2</a></li>
<li><a href="#">Secenek 3</a></li>
<li><a href="#">Secenek开发者_JAVA技巧 4</a></li>
</ul>
</div>
<!-- This code it doesnt work!-->
It is toggle menu script . When i was copy again this html code, It didnt work in ie9 and ie 7 What Can i do ?
Because you are using the same ID's more than once in the page. ID's should be unique (only one instance per page)
Try using classes instead.
$(document).ready(function(){
$(".yanMenu ul").hide();
$(".button").click(function(){
$(this).next().slideToggle("normal");
});
});
<div class="yanMenu">
<div class="button"><h5>Kategori 1</h5></div>
<ul>
<li><a href="#">Secenek 1</a></li>
<li><a href="#">Secenek 2</a></li>
<li><a href="#">Secenek 3</a></li>
<li><a href="#">Secenek 4</a></li>
</ul>
</div>
<div class="yanMenu">
<div class="button"><h5>Kategori 1</h5></div>
<ul>
<li><a href="#">Secenek 1</a></li>
<li><a href="#">Secenek 2</a></li>
<li><a href="#">Secenek 3</a></li>
<li><a href="#">Secenek 4</a></li>
</ul>
</div>
ID values should be unique (I would assume that your compiler may give you a warning if you have duplicated). These can fall under the same class or you can even use name attribute for your markup.
$('div[class="toggle"]').click(function(){.....}
<div id="button1" class="toggle">
<div id="button2" class="toggle">
...or name attribute instead of class but class is prob the preferable way to go
精彩评论