既然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