누구나이 코드가 크롬에서만 작동하는 이유를 알고 있습니까? 두 개 이상의 슬라이더를 추가하고 싶습니다. 그리고 나는 그들의 ID를 기반으로 조작하여 실험을 시작하고 있습니다! 여기jquery .attr()은 Chrome에서만 작동하나요?
<html>
<head>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" >
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".flip").click(function(){
var currentId = $(this).attr('id');
panel = "#panel"+currentId;
$(panel).slideToggle("slow");
});
});
</script>
<style type="text/css">
div.panel,p.flip
{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
div.panel
{
height:120px;
display:none;
}
</style>
</head>
<body>
<div class="panel" id="panel1">
<p>Because time is valuable, we deliver quick and easy learning.</p>
<p>At W3Schools, you can study everything you need to learn, in an accessible and handy format.</p>
</div>
<p class="flip" id="1">Show/Hide Panel</p>
<div class="panel" id="panel2" >
<p>Because time is valuable, we deliver quick and easy learning.</p>
<p>At W3Schools, you can study everything you need to learn, in an accessible and handy format.</p>
</div>
<p class="flip" id="2">Show/Hide Panel</p>
</body>
</html>
의 최신 버전을 사용하여 테스트 한 모든 브라우저에서 코드 한 일, 당신은 u는 할 수 없습니다 se "2"를 ID로 사용하면 문제가되지 않을 수도 있지만 시작할 장소입니다. –
이 코드는 Chrome, FF 및 IE8에서 잘 작동합니다 (데모 : http://jsfiddle.net/Jaybles/mAG7B/). JSFiddle은 jQuery 1.4.2를 제공하지 않기 때문에 jQuery 1.4.4를 사용하고있다. 아마도 jQuery 프레임 워크에 대한 업데이트가 필요합니다. – Dutchie432