아래 코드는 예상대로 작동하는 것 같습니다. — 배경색을 빨간색에서 파란색으로 토글합니다. (파이어 폭스 8.0과 크롬 17.0.942.0에서 테스트) :
<html>
<head>
<style type="text/css">
#popup{
position:relative;
height:100px;
width:100px;
margin:10px;
background-color:red;
}
.hide{
background-color:blue !important;
}
</style>
<script type="application/javascript" src="http://xuijs.com/downloads/xui-2.3.2.min.js"></script>
<script type="application/javascript">
x$.ready(function() {
document.getElementById('nearest').addEventListener('click', function(){
x$("#popup").toggleClass('hide');
}, false);
});
</script>
</head>
<body>
<div id="popup" class="hide"></div>
<input id="nearest" type="image" name="nearest" />
</body>
</html>
그냥 내가 document.getElementId()
원래 사용 가정 기능의 일부 또는 일부에 onLoad 스크립트로 묶인 확인? 작업 예제에서는 XUI ready()
함수를 사용하여 DOM이로드되었는지 확인했습니다. 그 그냥이 작동하지 않는,
x$.ready(function() {
x$('#nearest').click(function(){
x$("#popup").toggleClass('hide');
});
});
개 개별 작동 :
그것은 당신이 어쨌든 개 개별을 사용하고 있기 때문에 아래의 코드는, 해당하는 것을 주목할 가치가있다 – Harry