我可以将以下.htm文件复制到我的sony ericsson C510中,鼠标悬停工作正常:
<script type="text/javascript">
<!--
if (document.images) {
front = new Image
back = new Image
front.src = "front.png"
back.src = "back.png"
}
function swapImage(thisImage,newImage) {
if (document.images) {
document[thisImage].src = eval(newImage + ".src")
}
}
-->
</script>
<img onMouseOver="swapImage('test','back')"
onMouseOut="swapImage('test','front')"
src="front.png"
border="0"
name="test">
jquery-1.4.2.min.js
文件存在于正确的位置,因为我复制了目录中的所有文件:
<!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").click(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, primarily known for his operas (or "music dramas", as they were later called). Unlike most other opera composers, Wagner wrote both the music and libretto for every one of his works.</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>
如何让jquery像纯javascript一样在我的Sony Ericsson C510浏览器中工作?
根据rchern的建议,我尝试了以下方法:
<!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() {
$('#test').css("background-color","lightgreen");
alert("hi from jQuery");
});
</script>
</head>
<body>
<p>test from html</p>
<p id="test">jquery should turn this green</p>
</body>
</html>
在桌面上的firefox中,它显示弹出窗口并将行变为绿色,但在手机上jquery似乎没有效果,只显示文本。