Hello Friends这是我的代码
$this->widgets('ext.select.ESelect2', array(
'model' => $model,
'attribute' => 'state',
'data' => $data,
'htmloptions'=>array(
'multiple'=>'multiple',
),
'options' =>array(
'placeholder' => 'Select a state ...',
'allowClear'=> true,
),
));
如何在jquery中获取选项值和文本。我想要选择所选选项的值。 请建议并帮助我。
答案 0 :(得分:0)
您可以使用输入的类或ID来获取输入的值,请尝试以下方法:
$('#id_select_input').change(function() {
var selected = $(this).val();
var textValue = $this.text();
});
希望这会对你有所帮助。
$this->widgets('ext.select.ESelect2', array(
'id'=>'id_select_input',
'model' => $model,
'attribute' => 'state',
'data' => $data,
'htmloptions'=>array(
'multiple'=>'multiple',
),
'options' =>array(
'placeholder' => 'Select a state ...',
'allowClear'=> true,
),
));