jquery 1.9.1 on event not working

With Jquery v1.5.2 following function works, I have upgraded jquery to 1.9.1 live has been replaced to on function. if I change live to on. its not working.

I changed on to live and included the migration plugin its working. how can I use this with on function

$( ".pop-up" ).live(
                        "click",
                            function( event ){
                                // get the id of the item clicked on
                                var id = $(this).attr('id');
                                 alert(id)
                            // block the href actually working
                            return( false );

                            });

Answers


Try this

Instead of document you could use the selector that already exists in DOM, If this element is added dynamically to the DOM at a later time.

$(function(){
      $(document).on("click", ".pop-up",
        function( event ){
                            // get the id of the item clicked on
                            var id = $(this).attr('id');
                             alert(id)
                        // block the href actually working
                        return( false );
       });

});

Need Your Help

How to find current QLocale in Qt/PyQt/PySide?

python qt pyqt locale pyside

How can I find the currently active QLocale? We can find the default system locale with QLocale.system(), but I want something like QLocale.current(), to check if the locale changes I am trying to ...

Send executable jar to hadoop cluster and run as “hadoop jar”

hadoop cloud bigdata

I commonly make a executable jar package with a main method and run by the commandline "hadoop jar Some.jar ClassWithMain input output"

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.