via PCWorld http://www.techhive.com/article/2080849/netflix-nabs-breaking-bad-prequel-better-call-saul.html#tk.rss_all
Tech News is a blog created by Wasim Akhtar to deliver Technical news with the latest and greatest in the world of technology. We provide content in the form of articles, videos, and product reviews.
Netflix nabs Breaking Bad prequel Better Call Saul
via PCWorld http://www.techhive.com/article/2080849/netflix-nabs-breaking-bad-prequel-better-call-saul.html#tk.rss_all
Facebook’s auto-playing video ads may be a tough sell to users
via PCWorld http://www.techhive.com/article/2081123/facebook-s-auto-playing-video-ads-may-be-a-tough-sell-to-users.html#tk.rss_all
JQuery Trigger Event on Show/Hide of Element
JQuery provides powerful API to manage triggering of events. It provides a way to trigger the event handlers bound to an element without any user interaction via the
.trigger() method.
The .on() method (previously known as .live()) is a great way to add custom handlers to different browser events. When such events are triggered, these custom handlers are executed. This gives a great way to handle such events and perform certain activities.
The on() method can be used to add handlers to many build in events such as ‘click’, ‘change’ etc.
$('#foo').on('click', function() {
console.log('the foo was clicked');
});
However sometimes we want to add custom handler to events that JQuery does not implicitly provides.
One such useful event is on show or hide of an element. Lets say we want to add a handler when a particular DIV is shown.
Although this is not implicitly present in JQuery, we can still achieve this by writing a custom code that triggers the show/hide event when a DIV visibility is changed.
Just add below JQuery code snippet in your javascript file and voila, you can now handler ‘show’/'hide’ events using .on() method similar to other implicit events.
(function ($) {
$.each(['show', 'hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
Once the code is in place, you can simply use .on() method as below to add custom handler to show/hide event to any element.
$('#foo').on('show', function() {
console.log('#foo is now visible');
});
$('#foo').on('hide', function() {
console.log('#foo is hidden');
});
Online Demo
Here is a quick demo:
HTML Code
<button id="btnShow">Show</button>
<button id="btnHide">Hide</button>
<div class="container">
<div id="foo">
I am #foo
</div>
</div>
<div id="console">
</div>
CSS Code
.container {
height:60px;
margin:10px;
}
#foo {
background-color:#eeeeee;
width:150px;
height:50px;
text-align:center;
font-size:20px;
}
JQuery Code
//The magic code to add show/hide custom event triggers
(function ($) {
$.each(['show', 'hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
//on Show button click; show the #foo div
$('#btnShow').click(function(){
$('#foo').show();
});
//on Hide button click; hide the #foo div
$('#btnHide').click(function(){
$('#foo').hide();
});
//Add custom handler on show event and print message
$('#foo').on('show', function(){
$('#console').html( $('#console').html() + '#foo is now visible'+ '<br>' )
});
//Add custom handler on hide event and print message
$('#foo').on('hide', function(){
$('#console').html( $('#console').html() + '#foo is hidden'+ '<br>' )
});
JSFiddle: http://jsfiddle.net/viralpatel/975wJ/
Related Posts
- jQuery Live Event
- How to apply HTML User Interface Effects using jQuery.
- Tutorial: Handle browser events using jQuery JavaScript framework
- 20 Top jQuery Tips & Tricks for jQuery Programmers
- How to: Capture browser close button event or exiting the page in javascript.
- jQuery: Get the Text of Element without Child Element
- Dynamically shortened Text with “Show More” link using jQuery
via ViralPatel.net http://feedproxy.google.com/~r/viralpatelnet/~3/0BmSaGBPJiw/
How to view http cookie of webpage in Chrome browser
Google Chrome comes with a powerful Developer Tools. It is a bliss for web developer. Chrome’s Developer Tool has so many useful features that you would hardly miss anything that is not already there.
Here is a simple tip for those who are not already familiar with Chrome’s Developer Tools (F12). If you want to see what all cookies have been set on any webpage you can easily check that using Developer Tools. Follow these simple steps:
- Open the webpage whose cookies you want to analyze.
- Open Developer Tools in Chrome (Press F12)
- Goto Resources tab
- From below tree view, open Cookies view.
- Select the domain from the Cookies view list.
- Right hand side view will display all the cookies and other useful information.
See below screenshot (Click to enlarge).
Related Posts
- Chrome Experiment: Google’s new site to showcase Chrome and JavaScript
- Google Chrome released a new Beta
- Google Chrome drops BETA tag
- Google OS is here. Google launched Google Chrome OS
- From where Google brought logo of Chrome
- How to set third-party cookies with iframe
- Disable Back Button in Browser using JavaScript
via ViralPatel.net http://feedproxy.google.com/~r/viralpatelnet/~3/o9aEBhu_hF4/
Windows 11 Insider Preview Build 29560.1000 Released to New Canary Channel
UPDATE: Windows 11 Insider Preview build 29560.1000 released to the new Canary channel. Windows Insiders on the refreshed Canary Channel wil...
-
UPDATE: Direct download links added for the latest Mozilla Firefox 131.0.2, 115.16.1 ESR and 128.3.1 ESR offline installers. NOTE: The downl...
-
Newer versions of Windows 11 come with a new security feature called “Windows Protected Print Mode (WPP)“. This article will help you in act...