getelementsbyclassname

JS Events - for loop

霸气de小男生 提交于 2021-02-11 12:54:26
问题 I'm creating a website database which will have roughly 80-100 cards of individual products in each one. Inside the cards there is a + and - button which changes an input element. I have the counter code working fine but I need the buttons to be changing the input box in the card that is being pressed. Is there any way to focus the click event so that it changes the input element inside it's div? Should I be approaching this differently... This is the complete card HTML: <div class="card

Creating custom calculations using JavaScript (jQuery)

谁都会走 提交于 2021-02-11 12:26:13
问题 I wish to take the value of an HTML string contained within <bdi> tags - perform a calculation on it - and output the results in a separate <bdi> string, dependent on which input is selected on-page. The source <bdi> value changes dynamically based on user interaction, but I want to know if what I'm asking is feasible and a rough guide on how to achieve it? Screenshot to illustrate the user elements: In the DOM, the source value is nested in the below tag: <li class="grand_total"> <span class

Creating custom calculations using JavaScript (jQuery)

无人久伴 提交于 2021-02-11 12:25:09
问题 I wish to take the value of an HTML string contained within <bdi> tags - perform a calculation on it - and output the results in a separate <bdi> string, dependent on which input is selected on-page. The source <bdi> value changes dynamically based on user interaction, but I want to know if what I'm asking is feasible and a rough guide on how to achieve it? Screenshot to illustrate the user elements: In the DOM, the source value is nested in the below tag: <li class="grand_total"> <span class

How can I determine the value of the selected dropdown option using getElementsByClassName?

两盒软妹~` 提交于 2021-02-08 10:31:51
问题 How can I determine the value of the selected dropdown options using javascript. I can't use id selector so I was trying with document.getElementsByClassName. I understand that returns a set of values. Here is a simplified code I am trying to use: <div id="MDL" class="dates"> <p>Select Dates and Price</p> <select class="datevalue"> <option value="30">17th July - £30</option> <option value="45">17th July - £45</option> <option value="70">17th July - £70</option> <option value="30">18th July -

How can I determine the value of the selected dropdown option using getElementsByClassName?

。_饼干妹妹 提交于 2021-02-08 10:30:28
问题 How can I determine the value of the selected dropdown options using javascript. I can't use id selector so I was trying with document.getElementsByClassName. I understand that returns a set of values. Here is a simplified code I am trying to use: <div id="MDL" class="dates"> <p>Select Dates and Price</p> <select class="datevalue"> <option value="30">17th July - £30</option> <option value="45">17th July - £45</option> <option value="70">17th July - £70</option> <option value="30">18th July -

Why isn't getElementsByClassName working?

梦想的初衷 提交于 2021-02-04 21:56:48
问题 I can't understand why getElementsByClassName isn't working here. n = new Date(); y = n.getFullYear(); document.getElementByClassName("date").innerHTML = y; <span class="date"></span> CompanyName 回答1: The function name is getElementsByClassName , not getElementByClassName getElementsByClassName returns an array-like object of elements, not the one of elements. Code should look like this: n = new Date(); y = n.getFullYear(); document.getElementsByClassName("date")[0].innerHTML = y; <span class

Vanilla JavaScript adding classes to elements [duplicate]

ⅰ亾dé卋堺 提交于 2021-01-29 11:08:56
问题 This question already has answers here : Adding click event listener to elements with the same class (6 answers) Closed 2 years ago . I would like to use pure JS to add classes to some elements and am familiar with selecting the element with an ID, but when I've tried to use getElementsByClassName, my code breaks. Is it not possible to get elements by class name and add a new class? I know the following code works, but, again, would like to target the element by className. document

replacing all images from a class with another image using Javascript

情到浓时终转凉″ 提交于 2021-01-28 22:01:52
问题 I'm using an external script on my website with a form. Some of the css is customizable, but I can't change images for example. I would like to replace the small image displayed when a field is not completed by an other one using Javascript. This is the HTML code with the original image : <img class="incorrect-img" count="1" src="http://www.detailsdetails.eu/images/newimg/incorrect.gif"></img> I'm trying with this Js code but it's not working... $(document).ready(function () { document

using getElementByClassName in Safari

我的未来我决定 提交于 2021-01-27 23:57:47
问题 I'm trying to target Safari(both mobile and desktop) and append some styles for a class via Javascript . This is how my code looks like. (function safaristyles() { if (navigator.userAgent.match(/AppleWebKit/) && ! navigator.userAgent.match(/Chrome/)) { var avt = document.getElementsByClassName("avatar"); avt.style.border = "0" + "px"; avt.style.padding = "0" + "px"; } })(this); As I see it in Webkit inspector , this is the error I'm facing. Type Issue - 'undefined' is not an object

How to read the contents of a href with javascript?

二次信任 提交于 2021-01-24 19:05:13
问题 I have the following html and am stumped as to how to read the contents of the href tag? <p class="xyz-title"> <a href="http://www.youtube.com/embed/xyz"> <span class="field-content">Title here</span> </a> </p> I tried document.getElementByClass('xyz-title')[0].innerHTML but that didn't work obviously. Thanks very much for pointing me in the right direction. 回答1: It is a syntax error. It is supposed to be getElementsByClassName. Use this instead: document.getElementsByClassName('xyz-title')[0