0

I am wondering how to write a price in a div when a user selects an option in a dropdown menu.

Dave
  • 5,108
  • 16
  • 30
  • 40
  • 4
    What have you tried? Please provide your code so far so that we know how to help you. Additionally, we need context on what you're trying to achieve. The question of "how to write in a div" is very ambiguous. – Brandon Stillitano Oct 29 '19 at 17:32

1 Answers1

1

The information you provided was a little vague. However, based off of what you provided, I believe this is what you're attempting to accomplish.

<select id="myDropdown">
     <option id="opt1">Option 1</option>
     <option id="opt2">Option 2</option>
     <option id="opt3">Option 3</option>
     <option id="opt4">Option 4</option>
     <option id="opt5">Option 5</option>
</select>

<div id="result"></div>

If you have HTML like the above some where in your page, you can add some jQuery to the bottom of your page that should update your div accordingly.

<script type="text/javascript">
    $(document).ready(function() {
        $('#myDropdown').change(function() {
            $('#result').html('<span class="money">$123.45</span>');
        });
    });
</script>
Cliff Gunn
  • 458
  • 2
  • 7