dongqu9972 2017-03-02 00:39
浏览 56

更改textarea中的图像属性

I have the TinyMCE WYSIWYG text editor. The textarea for the text editor is called .seo_textarea after I hit submit I want all the images inside the textarea to have different data attributes. My logic is as follows:

  $('.social_properties_form').on('submit', function(e) {
            e.preventDefault();
            e.stopImmediatePropagation();

            imgOptimize();

                $.ajax({
                  type: 'POST',
                  url: '',
                  data: new FormData(this),
                  processData: false,
                  contentType: false,
                  success: function(data) {
                 window.location = "/profiles/articles.php";
                  }
                });
                }
        })

function imgOptimize(){
    $(".seo_textarea img").each(function(){
        var original = $(this).attr('src');
        $(this).attr('src', '/media/assets/loading-background.jpg');

        $(this).attr('data-src', original);

        var fileName = original.split('/').pop();

        $(this).attr('data-mobile-src', '/stories/media/images/mobile/' + fileName);
    });
}

Upon submission using Ajax to relay the information to PHP, a new row is inserted with the textarea's values. However, the textarea does not include extra data attributes for images. Instead, the original src is shown and nothing is changed.

How can I make it so that inside my database table I get the new data attributes and the changed src?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统