admin管理员组文章数量:1415644
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>
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?
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>
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?
3 Answers
Reset to default 3function changeId(id) {
$("#myExp param[name=id]").attr('value', id);
}
changeId(6);
Remember to actually call the function as well.
Unless I'm missing something obvious, this is what you're looking for in jQuery:
$("#myExp [name='id']").val(id);
This appears to work:
function changeId(id) {
$('#myExp [name=id]').val(id);
}
本文标签: javascriptDynamically changing an object parameter with jQueryStack Overflow
版权声明:本文标题:javascript - Dynamically changing an object parameter with jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745241358a2649346.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论