Use JS to make a mouse can drag the div (three)--Mobile with picture Div

Source: Internet
Author: User

When there is a picture element in the DIV element, it causes the drag to appear unexpectedly.

Because the picture element itself supports dragging, so long as the picture tag is added: Draggable= ' false '.

As follows:

<onmousedown= "Movebind (this, event)"  style= "Width:50px;height : 50px; left:285px;top:370px; Position:absolute; " ><  src= "Http://pic.cnitblog.com/face/614265/20140725231849.png"  draggable = "false" ></ Div >

Add dynamic Add-on elements:

    varContainerid = "Innercontainer"; varShowid = "Idshow"; varmoveelement = "Div"; functionaddelement (obj) {varimg = "<" + Obj.tagname + "src=" "+ obj.src +" ' draggable= ' false '/> '; varcontainer =findposition (document.getElementById (Containerid)); varContainerleft = container[0]; varContainertop = container[1]; varContainerwidth = container[4]; varContainerheight = container[5]; varleft = Containerleft + CONTAINERWIDTH/2-OBJ.OFFSETWIDTH/2; vartop = containertop + CONTAINERHEIGHT/2-OBJ.OFFSETHEIGHT/2; $("#" + Containerid). Append ("<div onmousedown= ' Movebind (this, event) ' style= ' width:" + obj.offsetwidth + "Px;height:" + Obj.offsetheight + "PX; Left: "+ Left +" Px;top: "+ top +" PX; Position:absolute; ' > "+ img +" </div> "); }

< Div >    <  src= "Http://pic.cnitblog.com/face/614265/20140725231849.png"  style= " width:50px; height:50px; " onclick = "AddElement (this)" /> </ Div >

Use JS to make a mouse can drag the div (three)--Mobile with picture Div

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.