Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Modal with jQuery Cookie"
Bootstrap 3.1.0 Snippet by
streetfire
3.1.0
jQuery
modal
jquery
Preview
HTML
JS
View Full Screen
Forked from
Fork
Fork this
Parent
1.3K
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!-- Referances jQuery Cookie : https://github.com/carhartl/jquery-cookie Modal : http://getbootstrap.com/javascript/#modals --> <script src="http://frontend.reklamor.com/jquery.cookie/jquery.cookie.js"></script> <div class="container"> <div class="row"> <div class='modal fade' id='myModal'> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class='modal-title'> <strong>Running Alpha™ Mobile</strong> </h4> </div> <!-- / modal-header --> <div class='modal-body'> <center> <img class="img-responsive" src="https://www.runningalpha.com/wp-content/uploads/2014/08/site-logo.png" width="200px"></center><br/> <p>Running Alpha.com is mobile responsive for viewing across all devices, but we recommend a desktop for <strong>optimum user experience</strong> as some features may not be available on the mobile version.</p> <a class="btn btn-primary btn-block" href="#">Continue to Mobile Version</a> <a class="btn btn-default btn-block" href="#">View Full Site</a> </div> <!-- / modal-body --> <div class='modal-footer'> <div class="checkbox pull-right"> <label> <input class='modal-check' name='modal-check' type="checkbox"><strong>Don't Show This Again</strong> </label> </div> <!--/ checkbox --> </div> <!--/ modal-footer --> </div> <!-- / modal-content --> </div> <!--/ modal-dialog --> </div> <!-- / modal --> </div> <!-- / row --> </div> <!-- / container -->
$(document).ready(function(){ //Referances //jQuery Cookie : https://github.com/carhartl/jquery-cookie //Modal : http://getbootstrap.com/javascript/#modals var my_cookie = $.cookie($('.modal-check').attr('name')); if (my_cookie && my_cookie == "true") { $(this).prop('checked', my_cookie); console.log('checked checkbox'); } else{ $('#myModal').modal('show'); console.log('uncheck checkbox'); } $(".modal-check").change(function() { $.cookie($(this).attr("name"), $(this).prop('checked'), { path: '/', expires: 1 }); }); });
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76