Find and replace certain part of value (jquery)
Posted
by
Hakan
on Stack Overflow
See other posts from Stack Overflow
or by Hakan
Published on 2011-01-09T18:32:59Z
Indexed on
2011/01/09
18:53 UTC
Read the original article
Hit count: 259
This might be a little complicated. See code below.
When image is clicked I want to change "MY-ID-NUMBER" in "value" and "src" of object. But I want the other information to remain.
When link is clicked I want to restore "value" and "src" so I can use the same function for next image that is clicked.
Is it possible? Please help!
My HTML:
<img height="186" width="134" alt="4988" src="i123.jpg">
<img height="186" width="134" alt="4567" src="i124.jpg">
<a class="restore-to-default" href="#">DVD</a>
<div class="tdt">
<object width="960" height="540"><param name="movie" value="http://www.domain.com/v3.4/player.swf?file=http://se.player-feed.domain.com/cinema/MY-ID-NUMBER/123-1/><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed id="player" name="player" type="application/x-shockwave-flash" src="http://www.player.domain.com/v3.4/player.swf?file=http://se.player-feed.domain.com/cinema/MY-ID-NUMBER/123-1/&display_title=over&menu=true&enable_link=true&default_quality=xxlarge&controlbar=over&autostart=true&backcolor=000000&frontcolor=ffffff&share=0&repeat=always&displayclick=play&volume=80&linktarget=_blank" width="960" height="540"allowFullScreen="true" allowScriptAccess="always"></embed></object>
My jquery:
$('img').click(function(){
var alt = $(this).attr("alt");
$('.tdt object').val("alt", alt); // Some how change "MY-ID-NUMBER" into the "alt-value" of image
});
$('a').click(function(){
//restore to "MY-ID-NUMBER"
});
Thanks!
© Stack Overflow or respective owner