0

I have created an select box using dd:

<select id="Size1"  class="mydds" style="width:180px;">
<option value="/p/1">1</option> 
<option value="/p/2">2</option>
<option value="/p/3">3</option>
</select>

Inside (document).ready I added the following line:

$(".mydds").msDropDown();

I tried to bind onchange using

$('.mydds').on('change',function() {
    alert("hiiiii");
});

But not able to bind the event can you help me on this?

sree
  • 868
  • 2
  • 12
  • 35

4 Answers4

1
$(document).ready(function(e) {

  var myddsAux = $(".mydds").msDropdown().data("dd");

  myddsAux.on('change', myddsFunction);

  var myddsFunction = function ( event ){
      alert("hiiiii");
  }
});

;)

PD: Documentation msDropdown

Yester668
  • 19
  • 3
0

Try this code

$(".mydds").on('change', 'select', function() {
alert(this.value);
});
0

You can get multiple variables from msDropdown, depending what you need,

here is example to get the text

        $(".mydds").change(function() {
            var oDropdown = $(".mydds").msDropdown().data("dd");
            var text = oDropdown.get("selectedText");
            console.log(text);
        });

there are also other properties available like:

  • selectedIndex - number
  • selectedOptions - array
  • value (select option value)
Aleksandar Pavić
  • 3,143
  • 1
  • 34
  • 36
0

Following is working for me

$(document).ready(function(e) {

    $(".mydds").on('change', 'select', function() {
        alert($(this).val());
    });

});
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89