You must Sign In to post a response.
  • Category: JQuery

    Custom Selector instead of $ and Jquery

    I faced a tricky question how to create custom selector in Jquery instead of $ and Jquery.

    Like we have use object notation $ or jquery

    But suppose user want to create custom like "Test". Could it possible if yes then please provide me the example.
  • #764726
    Hi jay,

    Yes it is possible. Please go through following URL's. You will get detailed knowledge about creating custom selector in jQuery:
    http://www.sitepoint.com/make-your-own-custom-jquery-selector/
    List of all available selectors:
    https://api.jquery.com/category/selectors/
    Find demo over here:
    http://jsfiddle.net/TrueBlueAussie/z3vwk1ko/36/
    Hope it helps.
    Regards,
    Shashikant Gurav
    shashikantgurav22@gmail.com

  • #764737
    Of course it is possible, please go through below thread and see how this can be achieved,

    http://stackoverflow.com/questions/25721390/is-it-possible-to-create-custom-jquery-selectors-that-navigate-ancestors-e-g-a

    http://www.sitepoint.com/make-your-own-custom-jquery-selector/


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM

  • #764909
    Hai Jay,
    The Custom selectors can be created using JQuery by extending the JQuery library as below:

    jQuery.extend(jQuery.expr[':'], { myCustomSelector: function (e) {
    //write the definition for the custom selector here
    });

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments