Selected show impossible

Topic: Selected show impossible

Scal68 pro asked 2 weeks ago

Hello, I just installed version 8.4 jquery and I can not display an option selected after a build of my select ajax. Can you help me ?

Bartłomiej Malanowski staff pro premium commented 7 days ago

What's your code? How can we reproduce your issue?

Scal68 pro answered 6 days ago

Hello Thanks for your help. If we take your example with the label and add selected to option 3, it does not appear at the top of the menu. Against if we remove the label it works. Is this normal?

 <select class="mdb-select md-form colorful-select dropdown-primary">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3" selected>Option 3</option>
  <option value="4">Option 4</option>
  <option value="5">Option 5</option>
<label class="mdb-main-label">Blue select</label>

TomekMakowski staff answered 6 days ago


Try this out

const val = $(".mdb-select option[selected]").val();

best, Tomek

Scal68 pro answered 5 days ago

Hello Thanks for your help. I still have the problem with the label that does not move places. I have placed your code in my jquery script. see the picture below

enter image description here

Scal68 pro answered 5 days ago

It works, I do not know why it did not work yesterday. thank you so much

TomekMakowski staff answered 4 days ago

You are welcome :D .

Scal68 pro answered 4 days ago

Hello I just found that if you put the select twice, the second selected does not work. So if there is more on the page, only the first works.

TomekMakowski staff answered 18 hours ago

So then try this script

    $(document).ready(function () {

    $(".mdb-select option[selected]").each(function(){
      let val = $(this).val();

Please insert min. 20 characters.


Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: jQuery
  • MDB Version: 4.8.4
  • Device: php jquery ajax
  • Browser: firefox
  • OS: win 10
  • Provided sample code: No
  • Provided link: No