خرید بک لینک

Vote count: 0

Is it possible to create a jQuery plugin that retus this.each for multiple matches allowing me to add a function property to each object within the each loop? I want to call this function later directly off of the object.

For example, here's a simplified version of what I'm trying to do:

(function ( $ ) {
  $.fn.roflcopter = function( options ) {

    retu this.each(function() {
        $(this).addClass('lol');
        $(this).getMyValue = function(e){
            retu retuMyFilteredValue($(this));
        }
    });

    function retuMyFilteredValue(elem){
        retu $(elem).val().replace("cat", "dog");
    }

  };
}( jQuery ));

I then want to in a document.ready function call this:

$("input.coolStuff").roflcopter();
var value = $("input.coolStuff").first().getMyValue();

Is this possible?

asked 56 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 17 فروردين 1395 ساعت: 8:36

صفحه بندی