I'am trying to get the value of the input type text in the following way:
$( document ).on( 'click', '.reset-to-default-img', function(e) {
alert($('#image').val());
});
When i click the button i got undefined alert message. I want to get the value. Not sure why. Here's my html:
<p>
<!-- Set Default Custom Image -->
<label for="widget-gallery-posts-widget[__i__][image]"></label>
<input name="widget-gallery-posts-widget[__i__][image]" id="widget-gallery-posts-widget-__i__-image" class="widefat" type="text" size="36" value="" />
<button class="upload_image_button button button-primary" type="button">Upload Your Custom Default Image</button> <br /> <br />
<img src="http://localhost/Gallery-Posts-Widget/wp-content/plugins/gallery-posts-widget/views/images/default-thumbnail.jpg" id="custom-default-img" width="150" height="100" />
</p>
I want to get the value of this input:
<input name="<?php echo $this->get_field_name( 'image' ); ?>" id="<?php echo $this->get_field_id( 'image' ); ?>" class="widefat" type="text" size="36" value="<?php echo esc_attr( $image ); ?>" />
Any ideas ?
imageid?[<>]toolbar button). That will help you get good answers more quickly.widget-gallery-posts-widget-__i__-imagenotimage