jQuery add value for data attributes by element’s id

Solution:

Try this:

 

    $.each($('svg .shop'), function (i, el) {
        var el = $(el);
        var id = el.attr('id');
        el.attr('data-title',`shop-name('${id}')`);
        el.attr('data-open',`shop-opening-hours('${id}')`);
    });

    console.log($('svg').html());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<svg>
    <g class="shop" id="215" data-title="" data-open=""></g>
    <g class="shop" id="217" data-title="" data-open=""></g>
    <g class="shop" id="218" data-title="" data-open=""></g>
</svg>