javascript - Variables in jQuery -


i have 2 questions this:

  1. i trying assign image variable img1 , insert variable img1 css, it's not working. doing wrong in code below? (note, code works fine if don't use variable i.e. if put image path directly it, know there must problem variable)

  2. assuming can img1 variable work, can somehow turn id or class can manipulate jquery? example, able $("img1").hide(1000) in same way class .contactform in code below.

    var img1 = url('/wp-content/themes/custom/images/blah.jpg') repeat;  $("#submit").click(function(){     $(".contactform").hide(1000,function(){         $(".contactforms").css({display:"block"});         $("body.custom").css({background: "img1"});      }); }); 

that's not valid javascript syntax. need wrap img1 in quotes it's recognized string. try this:

var img1 = "url('/wp-content/themes/custom/images/blah.jpg') repeat";  $("#submit").click(function(){     $(".contactform").hide(1000,function(){         $(".contactforms").css({display:"block"});         $("body.custom").css({background: img1});      });   }); 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -