getelementsbyclassname

Use vanilla javascript to add / remove class to a different element after clicking on another one

本秂侑毒 提交于 2019-11-29 12:55:37
问题 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 loop and iterating through the elements, but I got lost in the exact process. I have a number of elements with a class name of faq-container and when I click on any of them, I would like the class faq-display added to the body tag. I know I have to

Get ul li a string values and store them in a variable or array php [closed]

删除回忆录丶 提交于 2019-11-29 08:55:57
Im trying to store the string value's of a list item on my website into a variable/array in PHP to do some conditional checks/statements with them. Am having a bit off difficulty getting the list item's string value using PHP, can anybody help? This is the markup. <div class="coursesListed"> <ul> <li><a href="#"><h3>Item one</h3></a></li> <li><a href="#"><h3>item two</h3></a></li> <li><a href="#"><h3>Item three</h3></a></li> </ul> </div> What i want ideally is either a variable or array that holds the values "Item one", "Item two", "Item three". Try this $html = '<div class="coursesListed">

getElementsByClassName returns [] instead of asynchronous appended node

喜夏-厌秋 提交于 2019-11-29 05:16:24
(I ask my question again after the first one was terribly formulated) I face the following problem: <div class="testA" id="test1"></div> The above written element is predefined. I now load a xml tree via XMLHttpRequest & Co. delivering the following response: <response> <div class="colorSelector" id="0-0"> <div class="gbSelector" id="1-0"> <table style="none" id="2-0"></table> </div> </div> </response> I now append the first div using request.responseXML.getElementsByTagName("response")[0] .getElementsByTagName("div")[0] into the predefined div <div class="testA" id="test1"> The final document

How to get current element in getElementsByClassName

跟風遠走 提交于 2019-11-29 02:54:29
问题 Consider a simple JS event of document.getElementsByClassName('test')[0].onclick=function(){ document.getElementsByClassName('test')[0].innerHTML = 'New Text'; } How can I extend this code to generally work for all elements with class="test" . I mean getting the element clicked and replace its content. In fact, we need to get the node number (provided inside the bracket) from the click event. I am trying to better understand javascript in unobtrusive codes, not a practical method like jQuery.

pull data from website using VBA excel multiple classname

南笙酒味 提交于 2019-11-29 00:38:35
I know this has been asked many times, but haven't seen a clear answer for looping thru a div and findind tags with the same classname. My first question: If I have something like this: <div id="carousel"> <div id="images"> <div class="imageElement"> <img src="img/image1.jpg"> </div> <div class="imageElement"> <img src="img/image2.jpg"> </div> <div class="imageElement"> <img src="img/image3.jpg"> </div> </div> </div> So I want to get all the img Src in the div "images" along with other stuff in the imageElement classnames and copy them to some cells in excel. Second question: I've seen two

GetElementsbyClassname: Open IE vs. MSXML2 Methods

时光怂恿深爱的人放手 提交于 2019-11-28 12:35:51
The following macro works just fine. It opens an instance of IE and uses the "getelementsbyclassname" method to return the expected value for "my_rate". However when I run the second macro which uses the "MSXML2" method, the macro fails on the noted line and a "Run-time error 438: Object doesn't support this property or method" error occurs. Why does the "Open IE" method work, but the "MSXML2" method fail with my code? I am running with IE 11. I also have a reference set to the Microsoft HTML Object Library for the second macro, but it doesn't seem to make a difference. Thanks in advance for

getElementsByClassName to change the style of elements when event occurs [duplicate]

久未见 提交于 2019-11-28 11:30:12
This question already has an answer here: What do querySelectorAll and getElementsBy* methods return? 9 answers I'm trying to use onmouseover="document.getElementsByClassName().style.background='color'" to change the color of all divs with a given classname to another color when hovering over another page element. Here is a jsfiddle -if anyone could give a few helpful pointers as to where I'm going wrong that would be great, I'm sure it's something really obvious that I'm missing. It worked with document.getElementById, but that only changed the color of the first div, not all of them. Thanks

VBA: Choosing Specific Tab on Internet Explorer

耗尽温柔 提交于 2019-11-28 06:53:37
问题 I had another post regarding a different issue on the same overall problem here: Converting From Early Binding to Late Binding. I now have a new issue with my coding (which I will post a portion of it below), where if I have Internet Explorer open with multiple tabs, my code no longer fills in the text boxes - even if the tab is the one currently being viewed . As soon as I close all other tabs, the code runs flawlessly. If the tab was named Tab1 at the URL: https://sub.website.com/dir/ , how

Get ul li a string values and store them in a variable or array php [closed]

妖精的绣舞 提交于 2019-11-28 02:08:46
问题 Im trying to store the string value's of a list item on my website into a variable/array in PHP to do some conditional checks/statements with them. Am having a bit off difficulty getting the list item's string value using PHP, can anybody help? This is the markup. <div class="coursesListed"> <ul> <li><a href="#"><h3>Item one</h3></a></li> <li><a href="#"><h3>item two</h3></a></li> <li><a href="#"><h3>Item three</h3></a></li> </ul> </div> What i want ideally is either a variable or array that

getElementsByClassName not working but getElementById is

拟墨画扇 提交于 2019-11-27 08:49:17
问题 The following code works (alert pops up): var sound = document.getElementById("music"); sound.addEventListener("play", function () { alert("playing"); }); .... .... <audio controls id="music"> <source src="http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg"/> </audio> But why does this not work? var sound = document.getElementsByClassName("music"); sound.addEventListener("play", function () { alert("playing"); }); .... .... <audio controls class="music"> <source src="http://upload