Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

javascript - 如何通过我的自定义值设置HTML中的SELECT OPTION?(How to set SELECT OPTION in HTML by my custom value?)

I have a select field with some options in it.

(我有一个选择字段,里面有一些选项。)

Now I need to select one of those options with jQuery.

(现在,我需要使用jQuery选择这些选项之一。)

But how can I do that when I only know the value of the option that must be selected?

(但是,当我只知道必须选择的选项的值时,该怎么办?)

I have the following HTML:

(我有以下HTML:)

 <div class="id_100"> <select> <option value="val1">Val 1</option> <option value="val2">Val 2</option> <option value="val3">Val 3</option> </select> </div> 

I tried to do this with a tag but this does not work.

(我尝试使用标签来执行此操作,但这不起作用。)

Please tell me about other ways.

(请告诉我其他方法。)

Thanks in advance

(提前致谢)

  ask by Илья Равин translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...