2015-11-21 152 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。它超級酷和容易。感謝每一個