拖放后更改div的背景 [英] change background of div after drag&drop
问题描述
我在.aspx文件中有代码:
I have code in file .aspx:
<div id="divml5" class="dragDiv1" runat="server" style="width:40px; height:40px;position:relative; left:120px;top:60px;">
<table>
<tr>
<td>
<h5 id="h5ml5" class="handler" runat="server"
style="background-image:url('../../Images/image.jpg');
vertical-align:middle;width:40px; height:40px;background-repeat:no-repeat;"></h5>
</td>
</tr>
</table>
</div>
这是处理拖放的段落代码:
This is a paragraph code that processes drag&drop:
<script src="../Js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="../Js/jquery.dragndrop.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
var lat;
var log;
$('.dragDiv1').Drags({
handler: '.handler',
onDrop:function(e){
$('.content').html('Div Position:(Left:' + e.pageX + ' ,Top:' + e.pageY + ')');
lat = e.pageX;
log = e.pageY;
getLat();
getLog();
}
});
function getLat(){
return lat;
}
function getLog(){
return log;
}
});
</script>
拖放该元素后,我想更改其背景.在.cs文件中,我写道:
After drag&drop that element , I want to change it''s background. In file .cs, I wrote:
divml5.Attributes["style"] = "position:relative;top:" + @"getLat()" + "px;left:" + @"getLog()" + "px;";
h5ml5.Attributes["style"] = "background-image:url('../../Images/otherImage.jpg');vertical-align:middle;width:" + 40 + "px; height:" + 40 + "px;background-repeat:no-repeat;";
但是在文件.cs的段落代码中,我无法使用getLat()和getLog()函数来协调元素.
我不知道用于处理文件.cs中元素坐标的方法.
请帮我解决这个问题.
But in paragraph code in file .cs, I can''t get coordination of element with function getLat() and getLog().
I don''t know method to process coordinate of element in file .cs.
Please help me solve this problem.
Thank!
推荐答案
().ready(function(){ var lat; var log;
().ready(function() { var lat; var log;
('.dragDiv1').Drags({ 处理程序:.handler", onDrop:function(e){
('.dragDiv1').Drags({ handler: '.handler', onDrop:function(e){
('.content').html('Div Position:(Left:'+ e.pageX +',Top:'+ e.pageY + ')'); lat = e.pageX; log = e.pageY; getLat(); getLog(); } }); 函数getLat(){ 返回纬度 } 函数getLog(){ 返回日志; } }); < /script >
('.content').html('Div Position:(Left:' + e.pageX + ' ,Top:' + e.pageY + ')'); lat = e.pageX; log = e.pageY; getLat(); getLog(); } }); function getLat(){ return lat; } function getLog(){ return log; } }); </script>
拖放该元素后,我想更改其背景.在.cs文件中,我写道:
After drag&drop that element , I want to change it''s background. In file .cs, I wrote:
divml5.Attributes["style"] = "position:relative;top:" + @"getLat()" + "px;left:" + @"getLog()" + "px;";
h5ml5.Attributes["style"] = "background-image:url('../../Images/otherImage.jpg');vertical-align:middle;width:" + 40 + "px; height:" + 40 + "px;background-repeat:no-repeat;";
但是在文件.cs的段落代码中,我无法使用getLat()和getLog()函数来协调元素.
我不知道用于处理文件.cs中元素坐标的方法.
请帮我解决这个问题.
谢谢!
But in paragraph code in file .cs, I can''t get coordination of element with function getLat() and getLog().
I don''t know method to process coordinate of element in file .cs.
Please help me solve this problem.
Thank!
这篇关于拖放后更改div的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!