获取文本值我有各种图像类型下拉:从淘汰赛下拉
<select class="form-control" data-bind="options: imageCategoryList, value: 'Category', optionsCaption: --Select Category--, optionsText: 'Category', optionsValue: 'Category', event: {change: GetImages}" id="Category" name="Category"></select>
在我的JavaScript,我试图让无论是在下拉列表中选择的文本值,但我不知道该怎么做。在我看来,我有
var img = self.imageCategoryList().Text
但只返回“未定义”。我如何获得选定的文本值?
提前致谢!
我无法对你表示赞赏(我没有足够的声望),但非常感谢! – heztet
当我尝试用'var txt = newValue.Text'来代替'console.log(newValue.Text);'时,我得到了一个未定义的txt错误。如何记录selectedCategory的文本以在其他地方使用? – heztet
它可能只是您变量的范围。尝试将其分配给self.newTextValue而不是txt,并查看是否可以在其他地方访问它。 –