Show/hide div if it contains/not contains radio button value text
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a weird task on my new project. I have 2 radio buttons and I have to display certain dropdown divs based on the radio button selection. So radio buttons are 2 and divs are several more but I want it to show only certain divs, depending on radio button selection. I can't assign extra classes and IDs to the divs, so it came to me to try to make a javascript to check the value of radio and see, if it is contained in the div and display only divs that contain radio value. Here is the example:
EDIT: Added JS
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
EDIT2:
I forgot it should also affect another div with class select-selected to show the first of Radio2 divs. Now that is a bit tricky.
<div class="select-selected">1. Radio1 0</div>
This is on top of div with class select-hide.
I did not manage to make it. Any ideas how to do it or where to start over?
Regards!
javascript jquery html button radio
add a comment |
I have a weird task on my new project. I have 2 radio buttons and I have to display certain dropdown divs based on the radio button selection. So radio buttons are 2 and divs are several more but I want it to show only certain divs, depending on radio button selection. I can't assign extra classes and IDs to the divs, so it came to me to try to make a javascript to check the value of radio and see, if it is contained in the div and display only divs that contain radio value. Here is the example:
EDIT: Added JS
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
EDIT2:
I forgot it should also affect another div with class select-selected to show the first of Radio2 divs. Now that is a bit tricky.
<div class="select-selected">1. Radio1 0</div>
This is on top of div with class select-hide.
I did not manage to make it. Any ideas how to do it or where to start over?
Regards!
javascript jquery html button radio
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34
add a comment |
I have a weird task on my new project. I have 2 radio buttons and I have to display certain dropdown divs based on the radio button selection. So radio buttons are 2 and divs are several more but I want it to show only certain divs, depending on radio button selection. I can't assign extra classes and IDs to the divs, so it came to me to try to make a javascript to check the value of radio and see, if it is contained in the div and display only divs that contain radio value. Here is the example:
EDIT: Added JS
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
EDIT2:
I forgot it should also affect another div with class select-selected to show the first of Radio2 divs. Now that is a bit tricky.
<div class="select-selected">1. Radio1 0</div>
This is on top of div with class select-hide.
I did not manage to make it. Any ideas how to do it or where to start over?
Regards!
javascript jquery html button radio
I have a weird task on my new project. I have 2 radio buttons and I have to display certain dropdown divs based on the radio button selection. So radio buttons are 2 and divs are several more but I want it to show only certain divs, depending on radio button selection. I can't assign extra classes and IDs to the divs, so it came to me to try to make a javascript to check the value of radio and see, if it is contained in the div and display only divs that contain radio value. Here is the example:
EDIT: Added JS
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
EDIT2:
I forgot it should also affect another div with class select-selected to show the first of Radio2 divs. Now that is a bit tricky.
<div class="select-selected">1. Radio1 0</div>
This is on top of div with class select-hide.
I did not manage to make it. Any ideas how to do it or where to start over?
Regards!
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var text = div.innerHTML;
$("Radio1").not(text).hide();
$(text).show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
javascript jquery html button radio
javascript jquery html button radio
edited Nov 16 '18 at 13:01
lion
asked Nov 16 '18 at 12:22
lionlion
407
407
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34
add a comment |
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34
add a comment |
2 Answers
2
active
oldest
votes
You can do it like this... using jquery
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
add a comment |
You can add a change listener to both input[radio]
, then inside the listener function, you select all divs, hide them, and then loop through each one checking it's content, if it contains the radio.value
inside its textContent
then show it.
See below code, if it helps
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337835%2fshow-hide-div-if-it-contains-not-contains-radio-button-value-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do it like this... using jquery
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
add a comment |
You can do it like this... using jquery
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
add a comment |
You can do it like this... using jquery
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
You can do it like this... using jquery
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
$(document).ready(function(){
function xyz(){
var getval = $('label.container input[type="radio"]:checked').val();
$('.select-items>div').each(function(){
if($(this).text().indexOf(getval) > -1){
$(this).show();
}
else {
$(this).hide();
}
});
}
xyz();
$('label.container input[type="radio"]').click(function(){
xyz();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
edited Nov 16 '18 at 12:53
answered Nov 16 '18 at 12:38
ElusiveCoderElusiveCoder
1,4111420
1,4111420
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
add a comment |
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
This could work, too, but it displays both by default. Calvin Nunes answer was better and accepted as answer. Thank you, too, for spending time to answer!
– lion
Nov 16 '18 at 12:51
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Check now, it's as you need...
– ElusiveCoder
Nov 16 '18 at 12:54
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Great!! I think it was exactly what I was looking for! Is there a way to apply this to another div on the page, too?
– lion
Nov 16 '18 at 13:12
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
Yes, you can call the function xyz() anywhere on page, just change classes accordingly and you're done...
– ElusiveCoder
Nov 16 '18 at 13:19
add a comment |
You can add a change listener to both input[radio]
, then inside the listener function, you select all divs, hide them, and then loop through each one checking it's content, if it contains the radio.value
inside its textContent
then show it.
See below code, if it helps
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
|
show 4 more comments
You can add a change listener to both input[radio]
, then inside the listener function, you select all divs, hide them, and then loop through each one checking it's content, if it contains the radio.value
inside its textContent
then show it.
See below code, if it helps
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
|
show 4 more comments
You can add a change listener to both input[radio]
, then inside the listener function, you select all divs, hide them, and then loop through each one checking it's content, if it contains the radio.value
inside its textContent
then show it.
See below code, if it helps
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
You can add a change listener to both input[radio]
, then inside the listener function, you select all divs, hide them, and then loop through each one checking it's content, if it contains the radio.value
inside its textContent
then show it.
See below code, if it helps
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
$("input[name='radio']").on("change", (ev) => {
let elem = ev.target;
if (elem.checked){
let divs = $(".select-hide div")
let val = elem.value;
divs.hide()
divs.removeClass("select-selected")
divs.each((i, div) => {
let text = div.textContent
if (text.indexOf(val) > -1){
div.style.display = "block"
if (text.indexOf(val + " 0") > -1){
div.className += " select-selected";
}
}
})
}
})
//below code is to call the change when doc starts, to let radio1 selected
$("input[value='Radio1']").trigger("change")
.select-hide div{
display: none;
}
.select-selected{
color: green;
font-size: 20px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="container">Radio1
<input type="radio" checked="checked" name="radio" value="Radio1">
<span class="checkmark"></span>
</label>
<label class="container adult">Radio2
<input type="radio" name="radio" value="Radio2">
<span class="checkmark"></span>
</label>
<div class="select-items select-hide">
<div>1. Radio1 0</div>
<div>1.1. Radio1 - 1</div>
<div>1.2. Radio1 - 2</div>
<div>1.3. Radio1 - 3</div>
<div>1.4. Radio1 - 4</div>
<div>1.5. Radio1 - 5</div>
<div>1.5.1. Radio1 - 6</div>
<div>1.5.2. Radio1 - 7</div>
<div>1.5.3. Radio1 - 8 Loss</div>
<div>1.5.4. Radio1 - 9</div>
<div>1.6. Radio1 - 10</div>
<div>1.7. Radio1 - 11</div>
<div>2. Radio2 0</div>
<div>2.1. Radio2 - 1</div>
<div>2.2. Radio2 - 2</div>
<div>2.3. Radio2 - 3</div>
<div>2.4. Radio2 - 4</div>
</div>
edited Nov 16 '18 at 13:13
answered Nov 16 '18 at 12:34
Calvin NunesCalvin Nunes
3,71831135
3,71831135
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
|
show 4 more comments
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
Thanks a lot! That worked wonders but it does not change the value of <div class="select-selected">1. Radio1 0</div>. How do I make it apply to another div with class select-selected? I forgot to add this one div that displays the selected option from the dropdowns.
– lion
Nov 16 '18 at 12:38
1
1
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Sorry, didn't understand your need now. If it is a new question, please, create another one here in SO, since your main/initial question is already answered
– Calvin Nunes
Nov 16 '18 at 12:40
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
Where is dropdown? I can't see any here...
– ElusiveCoder
Nov 16 '18 at 12:41
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
I would like to make it apply not only for class select-hide but also for select-selected. Trying this... let divs = $(".select-hide .select-selected div")
– lion
Nov 16 '18 at 12:42
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
Tried this but it did not work, either. The point is, it should work on another div, too. let divs = $(".select-hide div, .select-selected div")
– lion
Nov 16 '18 at 12:48
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337835%2fshow-hide-div-if-it-contains-not-contains-radio-button-value-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you didn't try anything?
– Calvin Nunes
Nov 16 '18 at 12:25
I tried. Just added edit with JS I tried.
– lion
Nov 16 '18 at 12:30
You have to have some kind of identifier class or id. Or you have to get the inner text and parse it using regex or any other hack to operate on a specific collection of div or node.
– Shahadat Hossain
Nov 16 '18 at 12:34