jQuery, function called without parameters, but there is parameters -
one thing can't understand jquery, maybe can explain me this.
for example: html:
<div> <img class="class1" src="file.jpg" /> </div> <div> <img class="class2" src="file.jpg" /> </div>
jquery:
(function ($) { $(document).ready(function () { $('.class1, .class2').myfunction(); }); function myfunction(param1, param2) { var img = $('img', param1); } })(jquery);
so question in param1 , in param2, if function has been called that(without passing parameters function)?
the function call should follows:
view:
<div> <img id="img1" src="file.jpg" /> </div> <div> <img id="img2" src="file.jpg" /> </div>
jquery:
(function ($) { $(document).ready(function () { var path1 = $('#img1').attr('src'); var path2 = $('#img2').attr('src'); myfunction(path1, path2); }); function myfunction(param1, param2) { // code } })(jquery);
Comments
Post a Comment