admin管理员组文章数量:1326278
Here is the rundown of the problem:
console.log($("#clippy")); //For testing purposes. The element is properly selected.
//Next, I need to grab the text value I want to be copied into the clipboard...
var textToCopy = $(".permalink input[name='link']").text();
//How can I paste the value inside textToCopy inside the appropriate areas:
//Here's the exact HTML I need to manipulate, with the two params I need to modify.
//Labeled: "<-----HERE!"
/*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="25"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=sergio is the best champ"> <-------HERE!
<param name="bgcolor" value="#fff">
<embed src="../../Public/javascripts/clippy.swf"
width="110"
height="25"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage=""
FlashVars="text=sergio is the best champ" <--------AND HERE!
bgcolor="#fff"
/>
</object>*/
Assuming the value of textToCopy
was "Wele to The Matrix.", this would be the resulting HTML:
/*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="25"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=Wele to The Matrix."> <-------HERE!
<param name="bgcolor" value="#fff">
<embed src="../../Public/javascripts/clippy.swf"
width="110"
height="25"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage=""
FlashVars="text=Wele to The Matrix." <--------AND HERE!
bgcolor="#fff"
/>
</object>*/
Here is the rundown of the problem:
console.log($("#clippy")); //For testing purposes. The element is properly selected.
//Next, I need to grab the text value I want to be copied into the clipboard...
var textToCopy = $(".permalink input[name='link']").text();
//How can I paste the value inside textToCopy inside the appropriate areas:
//Here's the exact HTML I need to manipulate, with the two params I need to modify.
//Labeled: "<-----HERE!"
/*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="25"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=sergio is the best champ"> <-------HERE!
<param name="bgcolor" value="#fff">
<embed src="../../Public/javascripts/clippy.swf"
width="110"
height="25"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia./go/getflashplayer"
FlashVars="text=sergio is the best champ" <--------AND HERE!
bgcolor="#fff"
/>
</object>*/
Assuming the value of textToCopy
was "Wele to The Matrix.", this would be the resulting HTML:
/*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="25"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=Wele to The Matrix."> <-------HERE!
<param name="bgcolor" value="#fff">
<embed src="../../Public/javascripts/clippy.swf"
width="110"
height="25"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia./go/getflashplayer"
FlashVars="text=Wele to The Matrix." <--------AND HERE!
bgcolor="#fff"
/>
</object>*/
Share
Improve this question
edited Apr 27, 2012 at 21:04
Only Bolivian Here
asked Apr 27, 2012 at 21:00
Only Bolivian HereOnly Bolivian Here
36.8k65 gold badges166 silver badges257 bronze badges
3
-
2
$('#clippy').find('param[name="FlashVars"]').val(textToCopy);
and$('#clippy').find('embed').attr('FlashVars', textToCopy);
– Ohgodwhy Commented Apr 27, 2012 at 21:04 - I found this: stackoverflow./questions/1081656/object-param-jquery. See answer 3. – Steven Commented Apr 27, 2012 at 21:05
- @Ohgodwhy Can you post this as an answer? – Steven Commented Apr 27, 2012 at 21:10
1 Answer
Reset to default 6You can access the parameters of an object by finding the param by name:
$('#clippy').find('param[name="FlashVars"]').val(textToCopy);
You can access the attributes of the embed within the object like this:
$('#clippy').find('embed').attr('FlashVars', textToCopy);
本文标签: javascriptUsing jQuery to set values inside attributes of an Object elementStack Overflow
版权声明:本文标题:javascript - Using jQuery to set values inside attributes of an Object element? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742212730a2434011.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论