没有更多上下文并使用 jQuery。
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() { //this anonymous function will run when the page is ready
$("#button").hover(function() {
//mouse enter
var imgSrc = $("#prlogo img").attr("src");
//assumes there is an <img /> tag as a child of the #prlogo div
$("#input_2_16").val(imgSrc);
},function() {
//mouse leave
});
});
</script>
如果您不想在鼠标离开时做任何事情,您可以改为
$("#button").mouseenter(function() {
//mouse enter
var imgSrc = $("#prlogo img").attr("src");
//assumes there is an <img /> tag as a child of the #prlogo div
$("#input_2_16").val(imgSrc);
});