javascript - How to invoke a function onChange of an atrribute value in Jquery -
i'm trying invoke function onchange of attribute value. i'm trying is, when user clicks on 1 of below div
<div id="selected" class="vblock"> <div class="vblock"> <div class="vblock"> <div class="vblock"> <div class="vblock"> the value of src attribute of embed tag changed.
<embed id="vplayer" width="100%" height="100%" name="plugin" src="resources/videos/xyz21.mp4" type="video/mp4"> i need invoke function during alter of src value.
or
i need invoke function during modification of <div class="vblock"> <div id="selected" class="vblock">
what tried :
$('embed[src=#]').change(function(e){ // code please help me stuff...thanks.....
my thougth on problem:
1). improve close divs.
2). instead of <div id="selected" class="vblock"> should utilize <div class="vblock selected"> classes for.
3). can't hear attribute changes (well can, mutation events deprecated anyway..), can manually trigger event handler:
$('.vblock').on('click', function() { // something, set new src $('#vplayer').trigger('src:changed'); }); $('#vplayer').on('src:changed', function () { // src changed, }); javascript jquery
No comments:
Post a Comment