javascript - Why isn't this jQuery script replacing the video declaration with the GIF declaration on an HTML page -


i'm writing jquery script detect when user visiting website on ios device, , when are, switch background of website video gif, since .mp4 , .webm files aren't supported on ios version of safari. script uses modernizr.js , uisearch.js supporting files. script directly included in html, not separate file. here is:

$(document).ready(function() {     if((navigator.useragent.match(/iphone/i)) ||        (navigator.useragent.match(/ipod/i)) ||       (navigator.useragent.match(/ipad/i))) {        ('.video-background').remove();       ('body').prepend('<img src="./index_files/test_cut_gif.gif" id="backgroundimage" class="video-background">');     }   }); 

the html attempting change looks this:

<body  div="main" class="html front not-logged-in no-sidebars page-node page-node- page-node-16 node-type-panel role-1 lightbox-processed">   <div class="video-background">     <video id="video" preload="none" poster="./index_files" autoplay="autoplay" loop="true">       <source src="./index_files/test_cut_soundless_webm.webm" type="video/webm">       <source src="./index_files/test_cut_soundless_mp4.mp4" type="video/mp4">     </video>   </div> 

it's trying change this:

<body  div="main" class="html front not-logged-in no-sidebars page-node page-node- page-node-16 node-type-panel role-1 lightbox-processed">   <img src="./index_files/test_cut_gif.gif" id="backgroundimage" class="video-background"> 

i'm beginner programmer, , if shed light on what's not working here, appreciated!

in calling remove , prepend, have missing $ @ start

here:

('.video-background').remove(); ('body').prepend('<img src="./index_files/test_cut_gif.gif" id="backgroundimage" class="video-background">'); 

replace to:

$('.video-background').remove(); $('body').prepend('<img src="./index_files/test_cut_gif.gif" id="backgroundimage" class="video-background">'); 

i hope helps :)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -