I've got the script below  var els = document.getElementsByTagName("a"); for(var i = 0, l = els.length; i < l; i++) {   var el = els[i];   el.innerHTML = el.innerHTML.replace(/link1/gi, 'dead link'); }   However this searches t...
I have looked through a number of similar questions but can not find a specific example of one that answers in vanilla JS how to add and remove a class to a different element from the one clicked on. I know it has something to do with setting up a lo...
I am writing a script that needs to add DOM elements to the page, at the place where the script is located (widget-like approach). What is the best way to do this?  Here are the techniques I am considering:   Include an element with an id="Locato...
Am trying to read an XML response using getElementsByTagName:  var rows = items.responseXML.getElementsByTagName("z:row");  for (var i=0; i<rows.length; i++) { //do something }   Above code works fine in Firefox and IE but in chrome it thr...
I'm having trouble getting a selector to work properly.  I have this HTML:  <div.wrapper>     <div.ui-controlgroup-controls>         <form>             <div.ui-btn></div>         </form>         <div.ui-btn&...
Why is it that if I have only one h1 element in the document, I still have to use the index to access it?   Like the following doesn't work.  document.getElementsByTagName('h1').innerHTML = "SHUSHAN";   but if I do  document.getEl...
I used the following jquery to insert a metatag into a html document.   <script type="text/javascript"> if(screen.width>=320 && screen.width<=767){ $('head').append('<meta id="viewport" name="vie...
The website is: lexin.nada.kth.se/lexin/#searchinfo=both,swe_gre,hej;  My script is:  function main(){   var links=document.getElementsByTagName("a");   alert("There are " + links.length + "links."); }  main();   Running the s...
I have made this code:  var foo=document.createElement("div");  var childs=foo.getElementsByTagName("*");  console.log(childs.length);//0 OK  var a=document.createElement("a");  foo.appendChild(a);  console.log(childs.length);...
I have just started to learn native javascript and I am trying to write a simple script which will display an alert window showing the text contained in each <p></p> element.  I am posting the code below. Please let me know what I am doin...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.