Reputation: 902
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?
Upvotes: 0
Views: 2537
Reputation: 34
$(document).ready(function(e) {
var myddsAux = $(".mydds").msDropdown().data("dd");
myddsAux.on('change', myddsFunction);
var myddsFunction = function ( event ){
alert("hiiiii");
}
});
;)
Upvotes: 1
Reputation: 14523
Following is working for me
$(document).ready(function(e) {
$(".mydds").on('change', 'select', function() {
alert($(this).val());
});
});
Upvotes: 0
Reputation: 3420
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:
Upvotes: 0
Reputation: 174
Try this code
$(".mydds").on('change', 'select', function() {
alert(this.value);
});
Upvotes: 0