i have a slider. I want getting data from visible element li, and after putm them in my form inputs. How i can do this?
There is code
<div class="bx-wrapper" style="max-width: 100%; margin: 0px auto;"><div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 297px;">
<ul id="snap" class="bxslider" style="width: auto; position: relative;">
<li data-snap_id="654" data-title="ÐвÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop R30 (ЧеÑнаÑ)" data-image="wp-content/uploads/2014/08/r30.jpg" style="float: none; list-style: none; position: absolute; z-index: 50; display: block; width: 310px;"><img src="wp-content/uploads/2014/08/r30.jpg" title="ÐвÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop R30 (ЧеÑнаÑ)">
<div class="bx-caption"><span>ÐвÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop R30 (ЧеÑнаÑ)</span></div></li>
<li data-snap_id="658" data-title="ÐолÑавÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop Stamp Mouse R40 (ЧеÑнаÑ)" data-image="wp-content/uploads/2014/08/d5de5ccd5ade13bb4d8e82b4fa6371b5.jpg" style="float: none; list-style: none; position: absolute; z-index: 0; display: none; width: 310px;"><img src="wp-content/uploads/2014/08/d5de5ccd5ade13bb4d8e82b4fa6371b5.jpg" title="ÐолÑавÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop Stamp Mouse R40 (ЧеÑнаÑ)">
<div class="bx-caption"><span>ÐолÑавÑомаÑиÑеÑÐºÐ°Ñ Ð¾ÑнаÑÑка Colop Stamp Mouse R40 (ЧеÑнаÑ)</span></div>
</li>
<li data-snap_id="660" data-title="Ð ÑÑÐ½Ð°Ñ Ð¾ÑнаÑÑка D 30 мм" data-image="wp-content/uploads/2014/08/a6030d3f270432a8f138f8fe9d236b7c.jpg" style="float: none; list-style: none; position: absolute; z-index: 0; display: none; width: 310px;"><img src="wp-content/uploads/2014/08/a6030d3f270432a8f138f8fe9d236b7c.jpg" title="Ð ÑÑÐ½Ð°Ñ Ð¾ÑнаÑÑка D 30 мм">
<div class="bx-caption"><span>Ð ÑÑÐ½Ð°Ñ Ð¾ÑнаÑÑка D 30 мм</span></div>
</li>
</ul>
</div>
<div class="bx-controls bx-has-controls-direction">
<div class="bx-controls-direction">
<a class="bx-prev" href="">Prev</a>
<a class="bx-next" href="">Next</a>
</div>
</div>
</div>
This is jquery:
jQuery(".bx-prev", "bx-next").on('click', function() {
jQuery('#snap').find('li:visible');
var snap_id = jQuery(this).data('snap_id');
alert(snap_id);
});
fixed your code:
jQuery(this) shouldn’t be used in this case. The error was related to the selectors – jQuery(“.bx-prev, .bx-next”) You can try the code below: