'How to select specific value in a Query in HTML <script>
I need to know how to select a specific value in a form of a query.
Under the Content.join('');
, I need to select like 2 values which is the Hello and Lorem ipsum... then Hi and Nullam fringilla..., and so on.
Sorry, kinda new to this stuff as well.
<script>
var Count = 0;
var title = document.getElementById("getTitle");
var desc = document.getElementById("getDescription");
var Content = [
["Option1", "Hello", "Lorem ipsum dolor sit amet"],
["Option2", "Hi", "Nullam fringilla imperdiet eleifend"],
["Option3", "Greetings", "Cras dapibus ipsum a consequat tincidunt"]];
function previewImg(DibsSrc){
document.getElementById("Dibs").src =DibsSrc.src;
Content[Count][0] = DibsSrc.id;
title.innerhtml = Content.join('');
desc.innerhtml = Content.join('');
}
</script>
Solution 1:[1]
Content[0][1]
or Content[Count][1]
= Hello
Content[0][2]
or Content[Count][2]
= Lorem ipsum dolor sit amet
To check the next item you need to update the Count
var with a +1.
Content[1][1]
or Content[Count][1]
= Hi
Content[1][2]
or Content[Count][2]
= Nullam fringilla imperdiet eleifend
Note that the count starts with 0, so your first item is 0 instead of 1.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |