0
我有4个div和每个鼠标悬停,我想的src
改变。
我必须从PHP得到图像。
如何在我的jQquery脚本中使用我在PHP中获得的数组?
而我只知道4,我可以在JavaScript中设置数组并放置每个图像名称,但这不是我正在寻找的功能。在jquery中访问php数组
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
div{
height:100px;
width:100px;
display:inline-block;
background-color:blue;
}
#my_image{
height:100px;
width:100px;
display:inline-block;
}
</style>
<?php
$images = scandir("images", 1);
?>
<script>
$(document).ready(function(){
$(div).mouseover(function(){
$("#my_image").attr("src", /*my php array*/);
});
});
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<img id="my_image" />
</body>
</html>
我不清楚你最终的结果是什么。一张图像只能有一个SRC。 – Blazemonger
我希望src可以根据鼠标所在的div变成不同的图像。 – marseilles84