David :
Hello I am facing one issue , I am having two popovers and inside this I am passing html
Here is my code
<button class="count" data-toggle="popover">+click me</button>
<div class="popover_content_wrapper" style="display: none">
<p>Rahul</p>
</div>
<button class="count" data-toggle="popover">+click me</button>
<div class="popover_content_wrapper" style="display: none">
<p>Dravid</p>
</div>
In my Js Part
$(function() {
$('[data-toggle="popover"]').popover({ html : true,
content: function() {
return $('.popover_content_wrapper').html();
}
})
})
But if I click the first button it's working fine and showing "Rahul " in pop up
but if I click the second button it also showing "Rahul", but I want it to need to show "Dravid"
manikant gautam :
Just use $(this).next()
as it is immediate next div
to clicked button
.
$(function(event) {
$('[data-toggle="popover"]').popover({ html : true,
content: function() {
return $(this).next('.popover_content_wrapper').html();
// or $(this).next().html()
}
})
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<button class="count" data-toggle="popover">+click me</button>
<div class="popover_content_wrapper" style="display: none">
<p>Rahul</p>
</div>
<button class="count" data-toggle="popover">+click me</button>
<div class="popover_content_wrapper" style="display: none">
<p>Dravid</p>
</div>