javascript - Cannot get the input type value using jquery ← (PHP, JavaScript, JQuery)

Solution:

You should use closest method in combination with find method.

$( document ).on( 'click', '.reset-to-default-img', function(e) {
  var image=$(this).closest('p').find('.widefat').val();
});

Answer



Solution:

From your php method you are getting id widget-gallery-posts-widget-__i__-image not image so change your code as below

$( document ).on( 'click', '.reset-to-default-img', function(e) {
    alert($('#widget-gallery-posts-widget-__i__-image').val());
  });

Source