我想根据下拉列表中的值更改小程序标记的参数值。 我是 jquery 的新手。有人可以告诉我如何使用 jquery 做到这一点吗?
我的小程序代码:
<applet id="decisiontree" code="com.vaannila.utility.dynamicTreeApplet.class" archive="./appletjars/dynamictree.jar, ./appletjars/prefuse.jar" width ="1000" height="500" >
<param name="dieasenmae" value="Malaria"/>
</applet>
我的下拉代码:
<html:select name="AuthoringForm" property="disease_name" size="1" onchange="javascript:showSelected(this.value)">
<option>Malaria</option>
<option>High Fever</option>
<option>Cholera</option>
</html:select></p>
JavaScript:
function showSelected(value){
alert("the value given from dropdown is "+value);
$("#decisiontree param[name='dieasenmae']").val(value);
}
最佳答案
只需使用:
var myNewValue = 'my new value';
$("#decisiontree param[name='dieasenmae']").val( myNewValue );
直播example on JSBin .
选择器说明:
$("#decisiontree param[name='dieasenmae']")
^ ^ ^ ^
1 2 3 4
- 1 -> ID
decisiontree
内 - 2 -> 查找
param
类型的所有元素 - 3 -> 具有属性
name
- 4 -> 并且该属性值需要为
dieasenmae
现在您知道如何更改值,但这并不意味着它会起作用!因为您需要了解并了解<applet>
如何会正常工作,它会在开始时加载所有值,无论您在 DOM 中做什么,Applet 都可以忽略它......应该有一个 refresh applet
为此,最简单的方法是跟进这个问题:
Is there a way to reload/refresh a java applet from within the applet itself?
关于javascript - 如何使用jquery更改html标签中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7229427/