English 中文(简体)
Chosen Jquery Plugin - 获取选定的数值
原标题:Chosen Jquery Plugin - getting selected values

如何从选定的多功能方框中获取选定数值?

最佳回答

与任何经常性投入/选择/选择一样:

$("form.my-form .chosen-select").val()
问题回答
$("#select-id").chosen().val()

这对我来说是有效的。

$(".chzn-select").chosen({

     disable_search_threshold: 10

}).change(function(event){

     if(event.target == this){
        alert($(this).val());
     }

});
$("#select-id").chosen().val()

这是正确的答案,我尝试过,其价值是通过“、”分离的价值观。

如果任何人只想把选定的价值点击到一种选择中,他就可以做到如下:

$( .chosen-select ).on( change , function(evt, params) {
    var selectedValue = params.selected;
    console.log(selectedValue);
});

到2016年,你可以做的只是已经作出的任何答复:

$( #myChosenBox ).val();

在“MChosenBox”是原始选定投入的背后。 或者,在变化活动中:

$( #myChosenBox ).on( change , function(e, params) {
    alert(e.target.value); // OR
    alert(this.value); // OR
    alert(params.selected); // also in Panagiotis Kousaris  answer
}

change活动,即: 其他事件往往是一个不同的问题。

if you want to get text of a selected option (chosen get display selected value)

 $("#select-id").chosen().find("option:selected" ).text();

这一解决办法对我有利。

var ar = [];
$( #id option:selected ).each(function(index,valor){
    ar.push(valor.value);
});
console.log(ar);

be sure to have your <option> tags with they correspondant value attribute. Hope it helps.

我认为,由于Chosen将从原来的<条码>(选择)中复制该身份证,因此在以ID为对象时就会出现问题。 页: 1

在通过ID选定Chosen时,使用<代码>电子<>/代码>的选定器:

$(  select#yourID  ).on(  change , function() {
    console.log( $( this ).val() );
} );

......

$(  #yourID  ).on(  change , function() {
    console.log( $( this ).val() );
} );

之所以这样做,是因为Chosen将其选定的项目与原始(现为隐蔽的)<代码>(连多极的>选择要素相仿。

(It also continues to work with or without Chosen, say... if you decide to go a different direction in your application.)





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签