मैं बूटस्ट्रैप अलर्ट बॉक्स बनाने की कोशिश कर रहा हूं जो याद करता है कि उपयोगकर्ता बंद बटन पर क्लिक करते समय याद करते हैं। मुझे लगता है कि मुझे उस जानकारी को एक कुकी में स्टोर करने की आवश्यकता है। आदर्श रूप से कुकी केवल उस वर्तमान सत्र के लिए चली जाएगी, और अगले वे वापस बॉक्स फिर से दिखाई देंगे।बूटस्ट्रैप का उपयोग करके, अलर्ट बॉक्स को बंद करें
मैं jQuery-कुकी प्लगइन का उपयोग कर रहा हूं। मैंने इसे /jquery-cookie-master
पर अपलोड किया। प्लगइन found here हो सकता है।
यह कोड found here कोड का पालन करके मुझे अब तक मिला है।
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="/jquery-cookie-master/jquery.cookie.js"></script>
<script>
function runOnLoad(){
if($.cookie('alert-box') == null) {
$.cookie('alert-box', 'open', { expires: 7 });
} else if($.cookie('alert-box') == 'close') {
$(".close").hide();
}
</script>
HTML:
<body onload="runOnLoad()">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert" href="hideMe.php" onclick="hideMe()">×</button>
<p>
<strong>FORUM UPGRADE:</strong> In light of our recent surge in popularity we upgraded our forum and unfortunately lost all the old threads in the process.
</p>
<p>
In an effort to kick-start the forum again we need your help. Sign up now and leave a post (it's free). Once we reach 100 threads every member will receive a special gift.
</p>
<p>
<a href="http://example.com/forum/#/entry/register">
<strong>Sign up to the forum now</strong>
</a>.
</p>
</div>
</body>
दुर्भाग्य से यह working.When मैं बंद करें बटन यह है कि कार्रवाई याद नहीं है पर क्लिक करें और अगर मैं पेज को ताज़ा चेतावनी बॉक्स फिर से दिखाई देगा नहीं है।
मैंने क्या गलत किया है?
कर सकते हैं
का उपयोग कर jQuery आप निम्नलिखित कोड का उपयोग कर सकते एक घटना के लिए बाध्य करने के लिए कोई मदद करता है? – bennygill