Db to'plamidan olingan tasvirni haqiqiy tasvir sifatida ko'rsatish

Ma'lumotlar bazasi yig'ilishida rasmga kirish uchun jQuery'dan foydalanganman, ya'ni https: //somesite/img/somePhoto.png va keyin uni divtag-da namoyish qiling.

Men uni href matnini ko'rsatishim mumkin bo'lgan nuqtaga keltirdim, lekin men buni bir qadam oldinga olib chiqmoqchiman va aslida tasvirni o'zi ko'rsatishni istayman.

.html (message.media) - tasvir sifatida ko'rsatishga harakat qiladigan element

Bu erda hozircha kod mavjud

groupManager.prototype.displayChatMessage = function( message ){
    var _this = this;
    $('
')
        .attr("id",message._id)
        .text(message.message) //message text
        .html(message.media)//https://somesite/img/somePhoto.png
        .prepend($("").text(message.fromName+': '))
        .appendTo($('#messagesDiv'));
    $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
};
0
Iltimos, AngularJS yoki React kabi qo'shimcha usullardan foydalaning
qo'shib qo'ydi muallif chenop, manba

9 javoblar

u ishlay oladigan bu umidni sinashingiz mumkin.

groupManager.prototype.displayChatMessage = function( message ){
   var _this = this;
   var html = '
  • '; html += '

    '+ message.message +'

    ';//you can use different tag. html += ''; html += '' + message.fromName + ''; html += '
  • ';
       $('#messagesDiv').append(html);
       $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    };    
    
    1
    qo'shib qo'ydi
    Bu ishlaydi. Buni biroz o'zgartirishi kerak, biroq u rasmni ko'rsatadi. Katta rahmat.
    qo'shib qo'ydi muallif Thomas Degroot, manba

    u ishlay oladigan bu umidni sinashingiz mumkin.

    groupManager.prototype.displayChatMessage = function( message ){
       var _this = this;
       var html = '
  • '; html += '

    '+ message.message +'

    ';//you can use different tag. html += ''; html += '' + message.fromName + ''; html += '
  • ';
       $('#messagesDiv').append(html);
       $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    };    
    
    1
    qo'shib qo'ydi
    Bu ishlaydi. Buni biroz o'zgartirishi kerak, biroq u rasmni ko'rsatadi. Katta rahmat.
    qo'shib qo'ydi muallif Thomas Degroot, manba

    u ishlay oladigan bu umidni sinashingiz mumkin.

    groupManager.prototype.displayChatMessage = function( message ){
       var _this = this;
       var html = '
  • '; html += '

    '+ message.message +'

    ';//you can use different tag. html += ''; html += '' + message.fromName + ''; html += '
  • ';
       $('#messagesDiv').append(html);
       $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    };    
    
    1
    qo'shib qo'ydi
    Bu ishlaydi. Buni biroz o'zgartirishi kerak, biroq u rasmni ko'rsatadi. Katta rahmat.
    qo'shib qo'ydi muallif Thomas Degroot, manba

    Agar sizda href qiymati bo'lsa, uni ga qo'shing.

    Misol:

    $('a').attr('href', 'YOUR HREF VALUE');
    
    0
    qo'shib qo'ydi

    Agar sizda href qiymati bo'lsa, uni ga qo'shing.

    Misol:

    $('a').attr('href', 'YOUR HREF VALUE');
    
    0
    qo'shib qo'ydi

    Agar sizda href qiymati bo'lsa, uni ga qo'shing.

    Misol:

    $('a').attr('href', 'YOUR HREF VALUE');
    
    0
    qo'shib qo'ydi

    Quyidagi misolni tekshiring

    <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

    var _this = this;
    message = {message: 'abc', media: 'http://www.lets-develop.com/wp-content/uploads/2014/10/How-to-change-img-src-with-jQuery-change-img-url.jpg', fromName: 'ans'}
        $('
    ')
            .attr("id",message._id)
            .text(message.message) //message text
            .html('')//https://somesite/img/somePhoto.png
            .prepend($("").text(message.fromName+': '))
            .appendTo($('#messagesDiv'));
        $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="messagesDiv">
    
    </div>
    </div> </div>
    0
    qo'shib qo'ydi

    Quyidagi misolni tekshiring

    <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

    var _this = this;
    message = {message: 'abc', media: 'http://www.lets-develop.com/wp-content/uploads/2014/10/How-to-change-img-src-with-jQuery-change-img-url.jpg', fromName: 'ans'}
        $('
    ')
            .attr("id",message._id)
            .text(message.message) //message text
            .html('')//https://somesite/img/somePhoto.png
            .prepend($("").text(message.fromName+': '))
            .appendTo($('#messagesDiv'));
        $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="messagesDiv">
    
    </div>
    </div> </div>
    0
    qo'shib qo'ydi

    Quyidagi misolni tekshiring

    <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

    var _this = this;
    message = {message: 'abc', media: 'http://www.lets-develop.com/wp-content/uploads/2014/10/How-to-change-img-src-with-jQuery-change-img-url.jpg', fromName: 'ans'}
        $('
    ')
            .attr("id",message._id)
            .text(message.message) //message text
            .html('')//https://somesite/img/somePhoto.png
            .prepend($("").text(message.fromName+': '))
            .appendTo($('#messagesDiv'));
        $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="messagesDiv">
    
    </div>
    </div> </div>
    0
    qo'shib qo'ydi
    NodeJS Uzbekistan
    NodeJS Uzbekistan
    152 ishtirokchilar

    Guruh NodeJS bo'yicha muloqot qilish uchun ochilgan. Sizni qiziqtirsa: @nodejs_uz @react_uz @angular_uz @yiiframework_uz @js_uzb @typescript_uzb @vuejs_uz @ngTashkent @laravel_uz @uzdevgroup Ish o'rinlari @UzDev_jobs

    Javascript UZB
    Javascript UZB
    99 ishtirokchilar

    @js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb