Posts

Showing posts with the label dom

A new line for li's causes a JavaScript error [duplicate]

Image
A new line for li's causes a JavaScript error [duplicate] This question already has an answer here: What I meant by a new line I was referring to by forcing the text in the code editor to move down the next line for readability not to be confused by the n term. Any ways I have this script that removes the ul next sibling by pressing a button everything works perfectly but I did not like how in the code editor the two li's were next to each other so as soon as I put the second li on a new line my code generated an error on line 6 it said Uncaught TypeError: Cannot set property 'display' of undefined. This is what I mean in the code editor The non-working one document.addEventListener('DOMContentLoaded',function(){ document.querySelector('button').addEventListener('click',fx); function fx() { document.querySelector("#message li").nextSibling.style.display= 'none'; } }); <ul id='message'> <li>Coffee...

Multiple XML file reader and print as feed in HTML using jquery

Multiple XML file reader and print as feed in HTML using jquery Hello everybody I need to add an XML feed banner to a simple HTML website. I've got a variable number of XML files that contain some data placed in a directory in the root of this simple HTML website and named in random. I need to recursively print the XML tag "titolo" from those XML files in a HTML <div class="news"> meabe should be done with jQuery. <div class="news"> I need something like in this link http://jsfiddle.net/mVtCD/ but i need to read many random named files in my directory. This is the code of one of this random XML files: <?xml version="1.0" encoding="UTF-8"?><docfieg81> <metadati> <categoria>economia</categoria> <ambitoregionale>nazionale</ambitoregionale> <priorita>7</priorita> </metadati> <titolo>Inflazione +1,4%, stangata per famiglie</titolo> <testo> <p...

Show/hide element according to the selected option

Show/hide element according to the selected option I want to hide the speech response element , if the user selects the Tamil language from the drop down, but if the user selects English , the speech response element should be hidden. It doesn't work, I don't know why. Please, give me a suggestion on what's wrong with my code. Here is my code: function Speech(say) { if ('speechSynthesis' in window && talking) { $('#clitamilhide').hide(); var utterance = new SpeechSynthesisUtterance(say); speechSynthesis.speak(utterance); } } var msg = new SpeechSynthesisUtterance(ans); window.speechSynthesis.speak(msg); <select name="language_" id="langu" class="selectpicker form-control form-control-sm" style="width: 300px; margin-top: 125px;"> <option value="English"> English </option> <option value="Tamil"> Tamil </option> </select> In ...