既然my cell phone apparently doesn't support JQuery,但確實運行了我已經做過的簡單的Javascript測試,如何將下面的JQuery代碼轉換爲標準的Javascript?我將如何將此jQuery代碼轉換爲標準的JavaScript?
我所需要的只是基本的點擊隱藏/點擊顯示功能。
<!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">
<head>
<script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div > div.question").mouseover(function() {
if($(this).next().is(':hidden')) {
$(this).next().show();
} else {
$(this).next().hide();
}
});
});
</script>
<style>
div.flashcard {
margin: 0 10px 10px 0;
}
div.flashcard div.question {
background-color:#ddd;
width: 400px;
padding: 5px;
cursor: hand;
cursor: pointer;
}
div.flashcard div.answer {
background-color:#eee;
width: 400px;
padding: 5px;
display: none;
}
</style>
</head>
<body>
<div id="1" class="flashcard">
<div class="question">Who was Wagner?</div>
<div class="answer">German composer, conductor, theatre director and essayist.</div>
</div>
<div id="2" class="flashcard">
<div class="question">Who was Thalberg?</div>
<div class="answer">a composer and one of the most distinguished virtuoso pianists of the 19th century.</div>
</div>
</body>
</html>
工作!
謝謝bobince!
alt text http://www.deviantsart.com/upload/o61pba.jpg
也,你可以創建一個功能(不知道你的手機是否會支持這種功能...如: function showhideme(element){ element.style.display = element.style.display = =''? '沒有' : ''; } ...
– Nick 2010-07-06 23:56:15