Creating HTML/Javascript Modal with dynamic text

Advertisements I am learning Javascript and my project contains 3 buttons that open a modal. Everything works fine, however I want to reuse the modal and replace the modal text depending on which button is clicked. My HTML is below: <body> <button class="show-modal" id="btn-1">Show modal 1</button> <button class="show-modal" id="btn-2">Show modal 2</button> <button class="show-modal" id="btn-3">Show modal… Read More Creating HTML/Javascript Modal with dynamic text

Javascript to dynamically select based on another query

Advertisements I am working with a svg element as following const src = [{ “Name”: “Australia”, “Year”: 1997, “Value”: 15.540540540540499 }, { “Name”: “Australia”, “Year”: 1998, “Value”: 15.540540540540499 }, { “Name”: “Australia”, “Year”: 1999, “Value”: 22.4489795918367 }, { “Name”: “Brunei”, “Year”: 1998, “Value”: 6.4516129032258096 }, { “Name”: “Brunei”, “Year”: 2017, “Value”: 9.0909090909090899 }, { “Name”:… Read More Javascript to dynamically select based on another query

How to find from elements with one to multiple class names just the ones which feature exactly a specific and sole class name (and not any other)?

Advertisements Example: <div class="parent"> <div class ="parent father"> const soleParentClassElementList = document.querySelectorAll(‘.parent’) With the above code line I would query both element nodes, but I want to query just the one(s) with a single parent class. >Solution : this way… const onlyParent = document.querySelector(‘[class=”parent”]’) onlyParent.textContent = ‘this one’ <div class =”parent father”>…</div> <div class=”parent”> …… Read More How to find from elements with one to multiple class names just the ones which feature exactly a specific and sole class name (and not any other)?

How to select the last paragraph element ONLY if no other elements follow after her? (CSS selector question)

Advertisements How can I select the last paragraph <p> element, if and only its the last and lowest HTML element of the <article> element? I don’t want to use .classes or #id’s. A CSS selector should automatically find and select the <p> element. In my demo, in the first section, the last <p> element should… Read More How to select the last paragraph element ONLY if no other elements follow after her? (CSS selector question)