I have a div like this:
<div class="configurator-item">
<ul>
<li class="banner-list-img" data-price="122"></li>
</ul>
</div>
Inside this div I have added another div using jQuery:
Here's the jQuery:
jQuery('li.banner-list-img').prepend(jQuery('<div class="show-price"> </div>'));
After I run this jQuery a div is added:
<div class="configurator-item">
<ul>
<li class="banner-list-img" data-price="122">
<div class="show-price"> </div>
</li>
</ul>
</div>
Now I'm trying to get the value of data-price attribute to show inside the div(with class show-price with this jQuery:
jQuery('.banner-list-img').each(function() {
var itemprice = jQuery(this).text();
jQuery('.show-price').html(itemprice);
})
But this is not working. It should show something like this:
<div class="configurator-item">
<ul>
<li class="banner-list-img" data-price="122">
<div class="show-price"> 122 </div>
</li>
</ul>
</div>
How can I do like this.