If index.html and javascript not in the same folder, js does not work. Otherwise, it does

I’ve this simple index.html <html> <head> <title>Title</title> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> </head> <body> <script> alert(“Hello World”); </script> It’s <script src=”/js/date.js”></script> </body> </html> which should recall date.js document.write(new Date()); But unfortunately the date is not printed by the js The output is localhost says: Hello World and on the .html body only It’s. What’s…

JavaScript reading multiple images and displaying them in different div

My script: $(document).ready(function(){ var folder = “/img/gallery/”; $.ajax({ url : folder, success: function (data) { $(data).find(“a”).attr(“href”, function (i, val) { if( val.match(/\.(jpe?g|png|gif)$/) ) { $(“#galleryColumnOne”).append( “<img src='”+ folder + val +”‘>” ); $(“#galleryColumnTwo”).append( “<img src='”+ folder + val +”‘>” ); } }); } }); }); html: <body> <div class=”wrapGalleryList” id=”galleryColumnOne”></div> <div class=”wrapGalleryList” id=”galleryColumnTwo”></div> </body> Target:…

Javascript bookmarklet generates “SyntaxError: missing ) in parenthetical” error

I am stumped as to why this simple Javascript bookmarklet fails. javascript:(setInterval(function() { var element = document.getElementById(“observeBtn”); if (element != null) element.click(); }, 1000);)(); The error on the browser console is: SyntaxError: missing ) in parenthetical I’ve counted the parentheses, and they all match (7 left, 7 right). All this function is supposed to do…

JavaScript reading multiple images and displaying them in different div

My script: $(document).ready(function(){ var folder = “/img/gallery/”; $.ajax({ url : folder, success: function (data) { $(data).find(“a”).attr(“href”, function (i, val) { if( val.match(/\.(jpe?g|png|gif)$/) ) { $(“#galleryColumnOne”).append( “<img src='”+ folder + val +”‘>” ); $(“#galleryColumnTwo”).append( “<img src='”+ folder + val +”‘>” ); } }); } }); }); html: <body> <div class=”wrapGalleryList” id=”galleryColumnOne”></div> <div class=”wrapGalleryList” id=”galleryColumnTwo”></div> </body> Target:…