使用jQuery动态更改对象参数 [英] Dynamically changing an object parameter with jQuery
本文介绍了使用jQuery动态更改对象参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下HTML(为了这个问题而简化和剥离):
I have the following HTML (simplified and stripped for purposes of this question):
<html>
<head>
<title>My page</title>
</head>
<body>
<object id="myExp" class="myClass">
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<param name="width" value="560" />
<param name="height" value="310" />
<param name="id" value="1535" />
</object>
<script type="text/javascript">
function changeId(id)
{
// $('#myExp').
}
</script>
</body>
</html>
我要做的是做 changeId()
功能工作。它应该做的是用上面的 id $替换我的
< param name =idvalue =1535/>
以上一行c $ c>被传递到函数中。如何使用jQuery(或简单的旧javascript,如果需要)动态更改对象的
/ id
param
value?
What I am trying to do is make the changeId()
function work. What it should do is replace my <param name="id" value="1535" />
line above with whatever id
is passed into the function. How can I use jQuery (or plain old javascript, if need be) to dynamically change the id
of the object
/param
value?
推荐答案
function changeId(id) {
$("#myExp param[name=id]").attr('value', id);
}
changeId(6);
请记住实际调用该函数。
这篇关于使用jQuery动态更改对象参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文