JavaScript How to get selected radio button value from visibile HTML area? selected radio button html,selected radio button jquery,selected radio

I have following HTML with two ULs.

<a target='_blank' href="javascript:;" id="detail_buttons">Click</a>

<ul class="plan none">
    <li>
        <p>One month</p>
        <label for="2" class="label_radio">
            <input type="radio" value="40" id="2" data-name="Be Bold" name="be_bold">
        </label> <strong>40 ₪</strong>

    </li>
    <li>
        <p>Three months</p>
        <label for="3" class="label_radio">
            <input type="radio" value="70" id="3" data-name="Be Bold" name="be_bold" checked="checked">
        </label> <strong>70 ₪</strong>

    </li>
    <li>
        <p>Six months</p>
        <label for="4" class="label_radio">
            <input type="radio" value="100" id="4" data-name="Be Bold" name="be_bold">
        </label> <strong>100 ₪</strong>

    </li>
</ul>
<hr />
<ul class="plan">
    <li>
        <p>One month</p>
        <label for="2" class="label_radio">
            <input type="radio" value="40" id="2" data-name="Be Bold" name="be_bold_two">
        </label> <strong>40 ₪</strong>

    </li>
    <li>
        <p>Three months</p>
        <label for="3" class="label_radio">
            <input type="radio" value="70" id="3" data-name="Be Bold" name="be_bold_two">
        </label> <strong>70 ₪</strong>

    </li>
    <li>
        <p>Six months</p>
        <label for="4" class="label_radio">
            <input type="radio" value="100" id="4" data-name="Be Bold" name="be_bold_two">
        </label> <strong>100 ₪</strong>
    </li>
</ul>

First UL is with display: none and have one radio button is selected by default and Second UL is without selected.

Now I want get selected radio button value from visible UL.

Here is my jQuery Code:

$("#detail_buttons").click(function () {
    if ($(".plan input[type='radio']:checked").val() != undefined) {
        alert($(".plan input[type='radio']:checked").val());
    }
});

My JSFiddle: Sample

Any Idea?

Thanks.

Answer:1

I want to send Ajax request and perform some unrelated actions while data arrived. After finishing actions I like to wait for Ajax finishing and perform another actions. To be concrete lets see to ...

I want to send Ajax request and perform some unrelated actions while data arrived. After finishing actions I like to wait for Ajax finishing and perform another actions. To be concrete lets see to ...

  1. synchronous function async
  2. synchronous asynchronous function
  3. callback synchronous asynchronous
  4. synchronous asynchronous calls
  5. synchronous asynchronous method
  6. synchronous and asynchronous functions in javascript
  7. synchronous vs asynchronous functions
  8. synchronous and asynchronous functions in c
  9. synchronous vs asynchronous functions javascript
  10. synchronous and asynchronous functions in node js
  11. synchronous and asynchronous functions in autosar

I have a stacked column chart that shows 3 keys / values for each month stacked one on top of the other. Some months may have negatives. The current functionality is for highcharts to put two stacked ...

I have a stacked column chart that shows 3 keys / values for each month stacked one on top of the other. Some months may have negatives. The current functionality is for highcharts to put two stacked ...

  1. highcharts stacked column with line
  2. highcharts stacked column chart
  3. highcharts stacked column colors
  4. highcharts stacked column with drilldown
  5. highcharts stacked column total label
  6. highcharts stacked column multiple series
  7. highcharts stacked column change colors
  8. highcharts stacked column negative values
  9. highcharts stacked column order
  10. highcharts stacked column width
  11. highcharts stacked column sort
  12. highcharts stacked column show percentage
  13. highcharts stacked column with spline
  14. highcharts stacked column datetime
  15. highcharts stacked column chart colors
  16. highcharts stacked column time series
  17. highcharts stacked column click event
  18. highcharts stacked column data labels overlap
  19. highcharts stacked column percentage
  20. highcharts stacked column chart with negative values

This is a question about error propagation from react/flux actions into the store and then back to the component, the error is not validation, rather its an api call failure when trying to update the ...

This is a question about error propagation from react/flux actions into the store and then back to the component, the error is not validation, rather its an api call failure when trying to update the ...

  1. react flux error handling
  2. react-native-router-flux error

In javascript (jquery), I'm retrieving a list of elements that start with "#error-". This works correctly. The problem I have is that I can't assign a value to elements of the array while looping ...

In javascript (jquery), I'm retrieving a list of elements that start with "#error-". This works correctly. The problem I have is that I can't assign a value to elements of the array while looping ...

  1. iterate through list python
  2. iterate through list java
  3. iterate through list c++
  4. iterate through list javascript
  5. iterate through list of dictionaries python
  6. iterate through list of tuples python
  7. iterate through list bash
  8. iterate through list python with index
  9. iterate through list backwards python
  10. iterate through list scala
  11. iterate through list of strings python
  12. iterate through list ocaml
  13. iterate through list r
  14. iterate through list golang
  15. iterate through list haskell
  16. iterate through list matlab
  17. iterate through list kotlin
  18. iterate through list of objects python
  19. iterate through list groovy
  20. iterate through list java 8