动态更改html选择标记值

时间:2017-12-14 12:14:05

标签: javascript

我有一个选择标记

我想更改选择标记值def test_fill_tuple(): A = namedtuple("A", "aa, bb, cc") assert fill_tuple(A, None) == A(aa=None, bb=None, cc=None) assert fill_tuple(A, [None, None, None]) == A(aa=None, bb=None, cc=None) assert fill_tuple(A, [1, 2, 3]) == A(aa=1, bb=2, cc=3) assert fill_tuple(A, dict(aa=1, bb=2, cc=3)) == A(aa=1, bb=2, cc=3) with pytest.raises(TypeError) as e: fill_tuple(A, 2) assert e.value.message == "Cannot create 'A' tuple out of int (2)."

from value="-1:Select;" to value="-1:Select;2:option1"
  

值=" -1:选择;"

我尝试使用以下语法,但它没有改变:

<select role="select" value="-1:Select;" id="brandingName" name="brandingName" size="1" class="FormElement">
</select>

如何使用JavaScript或jQuery更改此值?

1 个答案:

答案 0 :(得分:3)

您需要选择id并使用attr来更改value,就像这样做而不进行测试。

$("#brandingName").attr("value", "-1:Select;2:option1")