vmars316 Posted September 4, 2019 Share Posted September 4, 2019 Hello & Thanks; I am making great progress on my project , thanks to you folks . But I do still have a problem with 'createElement' and 'appendChild' . They work fine but when I try to Drag the 'newly created div' it doesn't drag . If I saveAs the page and open the saved page , The created 'div' Drag works fine . So it seems that something is not getting updated dynamically . Pls , why does this happen , and how to fix it ? Run page here: http://vmars.us/ShowMe/changeImage-WIP-Try-Drag-Create.html Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2019 Share Posted September 4, 2019 First, instead of setAttribute("draggable" ) you should set the draggable property of the element, as element.draggable = true. Once the element has been created, you have to call the dragElement() function to add the event listeners to this element. Without the event listeners the element cannot be draggable. Link to comment Share on other sites More sharing options...
vmars316 Posted September 4, 2019 Author Share Posted September 4, 2019 Thanks Ingolme dragElement(MyNewDiv); Works great . I have another problem , same program: in here: <script> var copyFromVar = "one"; function saveItAll() { alert("Hello from function saveItAll()"); console.log("Hello from function saveItAll()"); var blankVar = ""; var fromList = document.getElementsByClassName("copyFrom"); var intoList = document.getElementsByClassName("pasteInto"); alert("fromList.length = " + fromList.length); for (var i = 0; i < fromList.length; i++) { alert("for (var i = 0; i < fromList.length; i++)"); console.log("fromList.length = " + fromList.length); copyFromVar = fromList[i].value ; console.log("copyFromVar = " + copyFromVar); intoList[i].innerHTML = copyFromVar; console.log("intoList[i].innerHTML = " + intoList[i].innerHTML); } } // </script> None of the console.log() statements work . And the second alert() doesn't work . Any idea why nothing works beyond the 1st alert() ? Thanks I'll Post the whole code if you wish . Link to comment Share on other sites More sharing options...
justsomeguy Posted September 4, 2019 Share Posted September 4, 2019 If not even that first console.log works then it sounds like it's not running at all. If the first alert works but not console.log and not the second alert, maybe the browser that you're using does not have console.log defined. Link to comment Share on other sites More sharing options...
vmars316 Posted September 5, 2019 Author Share Posted September 5, 2019 Oops... The 1st and 2nd alert()s both work but no console.log()s work . And no errors show up on the console . Run code from here: http://vmars.us/ShowMe/changeImage-Drag-Create-Restore.html Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted September 5, 2019 Share Posted September 5, 2019 I see the message in the console. Link to comment Share on other sites More sharing options...
vmars316 Posted September 5, 2019 Author Share Posted September 5, 2019 (edited) Oops yes , the first console.log() works , then no more . I am running chrome . Is there a way to turn on/off console in all browsers ? I am guessing it's always running . Thanks Edited September 5, 2019 by vmars316 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 5, 2019 Share Posted September 5, 2019 I'm not sure if browsers have a way to disable the developer tools or the console specifically. Probably not, because if so then any code that tries to use the console would be a fatal error and the code would stop running. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now