jquery - HTML not working with JavaScript -


this question exact duplicate of:

it seems javascript won't run when put in html <script></script> works fine online tool. javascript should able replace image video when image clicked. how can add html?

it work fine while using online tool http://jsfiddle.net/odoycz6n/3/

html

<img src="http://www.whatever9495.com/template/damei_d21/image/logo.png" data-video="https://drive.google.com/file/d/0bwbk-p9knhkga21vszyzmfl6yxm/preview"> 

javascript

$('img').click(function() {   video = '<iframe src="' + $(this).attr('data-video') + '"   width="715" height="480" frameborder="0" allowfullscreen=""></iframe>';   $(this).replacewith(video); }); 

jsfiddle loads jquery default. need load jquery before using in own code like

<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script> 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -