I'm using CSS Bootstrap's Modal feature, and it's working perfectly. However, I want to add a functionality that while the modal dialog is open and the rest of the web page is covered up by the .modal-backdrop, one of the outside elements from a different place within the scope of the page's structure can be exposed on top of the backdrop:
<div id="outside-element">
I want this element exposed even while the modal is active,
upon clicking the button in the modal dialog box
</div>
<div id="help-box" class="modal fade" data-backdrop="static" data-keyboard="false" data-show="true" tabindex="-1" role="dialog" aria-labelledby="help-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
Click this button to show the outside element:
<button type="button" class="btn" aria-hidden="true" id="test-item">Click it!</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function($) {
$('#test-item').click(function() {
$('#outside-element').attr('style','zIndex:1041');
});
})(jQuery);
</script>
As you can see in my current attempt above, I'm setting the z-index of the outside element to 1041, which is one higher than the .modal-backdrop setting (1040). This is not accomplishing what I want it to (namely, placing the #outside-element on top of the modal backdrop), even though the code is sound and "working" (that is, it's definitively modifying the z-index).
It would be great if you have a fiddle to show your code in a way that we can run it and see what's going on.
You will need to include the position of the element, for a z-index to take effect:
#outside-element {
position: relative;
z-index: 1041;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With