未经许可,更改了按钮值

时间:2017-08-19 09:00:02

标签: javascript jquery html button

我有一个" upload_image_button"并以这种方式处理按钮:

jQuery(document).ready(function($) {
 $( document ).on( 'click', '.upload_image_button', function(e) {
        e.preventDefault();
        var uploadButton = $(this)

         mediaUploader = wp.media({
          title: 'Choose Image',
          button: {
          text: 'Choose Image'
        }, multiple: false });

        mediaUploader.on('select', function() {
          var attachment = mediaUploader.state().get('selection').first().toJSON();
          var id = uploadButton.attr('image');
          $('.upload_image_button').parent().children('input').val(attachment.id);
        });

        mediaUploader.open();

    });
});

问题是,当我上传图片时,按钮值会更改为图片网址。我不确定它会改变吗? 这是按钮字段:

<input class="upload_image_button button button-primary" type="button" value="Upload Your Custom Default Image" />

0 个答案:

没有答案