javascript - How to add delay only when the function is called? -


i trying call function delay.

       window.setinterval(function(){          //$('.product-display').delay(3000).hide();         document.getelementbyid('product-list-display').style.display = "none";         },3000); 

the above code hides div after 3 seconds, above snippet called in show div function. need is, want invoke the above delay function when show div function called...right function executes every 3 secnds i.e using setinterval hiding. want hide after 3 seconds when show div called. how can this? can use jquery?

function showdiv(city, imagesrc, timeout) {    window.settimeout(function() {      document.getelementbyid('city-order').innerhtml = "";     document.getelementbyid('order-product').innerhtml = "";      $('.product-display').addclass("zoomin");        document.getelementbyid('product-list-display').style.display = "block";      var order_placed_city = document.getelementbyid('city-order');     var content = document.createtextnode(city);     order_placed_city.appendchild(content);      var product_order = document.getelementbyid('order-product');     var elem = document.createelement("img");     product_order.appendchild(elem);      elem.src = imagesrc;    },timeout);      window.settimeout(function(){          //$('.product-display').delay(3000).hide();          document.getelementbyid('product-list-display').style.display = "none";    },3000); } 

move hide settimeout 1 line :

function showdiv(city, imagesrc, timeout) {     window.settimeout(function() {         document.getelementbyid('city-order').innerhtml = "";         document.getelementbyid('order-product').innerhtml = "";         $('.product-display').addclass("zoomin");           document.getelementbyid('product-list-display').style.display = "block";         var order_placed_city = document.getelementbyid('city-order');         var content = document.createtextnode(city);         order_placed_city.appendchild(content);         var product_order = document.getelementbyid('order-product');         var elem = document.createelement("img");         product_order.appendchild(elem);         elem.src = imagesrc;          window.settimeout(function(){             //$('.product-display').delay(3000).hide();             document.getelementbyid('product-list-display').style.display = "none";         },3000);      },timeout);  } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -