<option>值为<input />文本值

时间:2016-09-29 12:16:16

标签: javascript jquery html select

我正在尝试从select元素设置输入框的值和文本。

var p = document.getElementById("pretestNameSelect");
var test = p.options[p.selectedIndex].value;
if (choice.toString() == "type0")
{
    alert(test);
    $(document.getElementById("type0")).show();
    hideOtherQuestionDivs(choice.toString());        
    $(document.getElementById("pretestNameSelectHiddenTextQ0")).value = "test";
    $(document.getElementById("pretestNameSelectHiddenTextQ0")).text = "test";
    alert(document.getElementById("pretestNameSelectHiddenTextQ0").value);
}

警报(测试)工作并显示正确的值,但未设置值,警报(doc ...)显示空警报。

可能是什么问题?

1 个答案:

答案 0 :(得分:2)

您正在将Jquery选择器与DOM选择器混合使用。

您可以使用

library(arules)
data("Adult")
rules <- apriori(Adult, parameter = list(supp = 0.5, conf = 0.9, minlen = 2))
item <- "race=White"
rules.sub <- subset(rules, lhs %in% item & size(lhs)==1)
inspect(rules.sub)
#   lhs             rhs                            support   confidence lift     
# 7 {race=White} => {native-country=United-States} 0.7881127 0.9217231  1.0270761
# 8 {race=White} => {capital-gain=None}            0.7817862 0.9143240  0.9966616
# 9 {race=White} => {capital-loss=None}            0.8136849 0.9516307  0.9982720

$('#pretestNameSelectHiddenTextQ0').val(test);