当我创建一个选择菜单时,它位于当前网址的第一个位置: [英] As I create a select menu, which is in the first position with the current url:
本文介绍了当我创建一个选择菜单时,它位于当前网址的第一个位置:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我创建一个选择菜单时,该菜单位于当前URL的第一位置,更改option
的selected
:
As I create a select menu, which is in the first position with the current URL, changing the selected
of option
:
<select >
<option value="http://www.test.com/teste1" selected>test1</option>
<option value="http://www.test.com/teste2">Google</option>
<option value="http://www.test.com/teste3">YouTube</option>
<option value="http://www.test.com/teste4">test 4</option>
</select>
示例浏览器URL http://www.test.test.4
:
<select >
<option value="http://www.test.com/teste4" selected>test 4</option>
<option value="http://www.test.com/teste1/">test1</option>
<option value="http://www.test.com/teste2">Google</option>
<option value="http://www.test.com/teste3">YouTube</option>
</select>
推荐答案
我不确定是否理解,您是否在所有页面上都包含此代码,并且想要更改所选选项?
I'm not sure to understand, you include this code on all of this pages and you want to change selected option ?
也许您可以使用JS(在每页上)执行onload事件来实现它.
Maybe you can do it with JS with the onload event on your body (on each pages).
http://www.test.com/teste2 正文的示例:
如何我如何使用javascript以编程方式设置选择框元素的值?
<body onload="selectElement('http://www.test.com/teste2')">
这篇关于当我创建一个选择菜单时,它位于当前网址的第一个位置:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文