我使用jQuery UI插件拖放我的对象,但我有一个问题。 我的HTML源代码是这样的:如何在“jQuery Ui Draggable Helper”中调用函数参数?
<html>
<body>
<div id="firstDiv">some thing is here</div>
</body>
</html>
现在,我想拖动上面的DIV,使用帮手。我的代码是这样的:
<script type="text/javascript">
$(document).ready(function(){
$("#firsstDiv").draggable({helper:anImage});
});
function anImage() {
return '<img src="~/myImage.png" alt="" />';
}
</script>
好吧,这个代码是工作为好,但我想设置图像的地址,但是当我改变我的函数有一个参数,即不工作,O_O
我新代码是这样的:
<script type="text/javascript">
$(document).ready(function(){
$("#firsstDiv").draggable({helper:anImage($(this).text())});
});
function anImage(address) {
return '<img src="'+address+'" alt="" />';
}
</script>
但不工作。
感谢您的帮助。
你想你的函数采取的地址作为参数?你能发布你试过的代码吗?什么不行? – 2012-04-11 11:43:39
** ** – mhdrad 2012-04-11 11:48:15