2015-11-21 148 views
0

我是新来的jquery我有以下代码,但拖放功能不起作用。文本正在按预期进行更新,但拖动不起作用。请帮助拖放图像使用jquery

$(document).ready(function(){ 
 
    $("#title").keyup(update); 
 
}); 
 

 
function update(){   
 

 
    var title = $("#title").val(); 
 
    $("#Displaytitle").html(title); 
 

 
    $("#Displaytitle").draggable(); 
 
    $("#Displaytitle").droppable({ 
 
    drop: function(event, ui) { 
 
     var $text = $("#Displaytitle").text(); 
 
     $(this).addClass("ui-state-highlight").find("p").html($text); 
 
     // $("#msg").hide(); 
 
    } 
 
    }); 
 
}
<form> 
 
    <input name="title" type="text" class="click" id="title" value=" " size="25" /> 
 
    <br/> 
 
    <img name="pic" class="click" id="photo" src="maritime.jpg" width="500" height="500" /> 
 
    <!-- </select> where is the opening tag ? --> 
 
    <br/> 
 
</form> 
 
<!-- </div> where is the opening tag ? --> 
 
<p id="Displaytitle"></p>

+0

你有2个无用的结束标签在你的HTML,我已经评论他们。 – sodawillow

回答

0

我得到了答案here。它超级酷和容易。感谢每一个