how to pass value to a function in jquery -


i passing value true function below can me.....
can use simple javascript function in place of jquery sake of knowledge want make in way.

js:

$(document).ready(function(){   $("#slider").click(function(){     $("#slider").suyesh(true);     }); });  (function($){     $.fn.suyesh = function(s){         if(s == true){             alert("value coming");                }         } })(jquery); 

html :

<div id="slider">         <ul class="slide">             <li class="slide_1"><img src="1.jpg"></li>             <li class="slide_2"><img src="2.jpg"></li>             <li class="slide_3"><img src="3.jpg"></li>             <li class="slide_4"><img src="4.jpg"></li>             <li class="slide_5"><img src="5.jpg"></li>         </ul>     </div> 

it sounds you're looking @ creating jquery plugin. try like:

(function($) {     $.fn.suyesh = function(myarg) {         if (myarg) {             // put code here thing if true passed in.             // i.e. this.css("color", "green");         } else {             // put code here thing if false passed in.             // i.e. this.css("color", "red");         }         return this;     };  }(jquery)); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -