Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Friday, 25 September 2015

How to clear File Input

You can just clone it and replace it with itself, with all events still attached:'

<input type="file" id="control">


var input = $("#control");

function something_happens() {

Wednesday, 16 October 2013

jQuery check if element is visible or hidden

Useful jQuery toggle visibility methods.

Or you may check if element is visible or hidden with jQuery. Hide or show it according to its visibility.
Test code:
<div class="wrap-js-action"><span class="click js-action">click to show or hide (display:block|none;)</span></div>
<div class="target">target</div>
<div class="wrap-js-action"><span class="click-toggle js-action">click to show or hide by toggle (display:block|none;)</span></div>
<div class="target-toggle">target-toggle</div>
<div class="wrap-js-action"><span class="click-visibility js-action">click to show or hide (visibility:hidden|visible)</span></div>
<div class="target-visibility">target visibility</div>
<div class="wrap-js-action"><span class="click-opacity js-action">click to show or hide (opacity:0|1)</span></div>
<div class="target-opacity">target opacity</div>
<div>last line</div>
$('.click').click(function() {
    if ($('.target').is(':hidden')) {
    } else {
$('.click-toggle').click(function() {
$('.click-visibility').click(function() {
    if ($('.target-visibility').css('visibility') == 'hidden'){
        $('.target-visibility').css({'visibility': 'visible', display: ''});
        $('.target-visibility').css({'visibility': 'hidden', display: ''});
$('.click-opacity').click(function() {
    if ($('.target-opacity').css('opacity') == '0'){
        $('.target-opacity').css({'opacity': '1', display: ''});
        $('.target-opacity').css({'opacity': '0', display: ''});
.js-action {
    cursor: pointer;
    border-bottom:1px dashed #555;

.wrap-js-action {
    margin:15px 0 0 0;
Difference between "display:none", "visibility:hidden" and "opacity:0":
  • display:none hides the element and it does not take up any space;
  • visibility:hidden hides the element, but it still takes up space in the layout;
  • opacity:0 hides the element as "visibility:hidden" and it still takes up space in the layout; the only difference is that opacity let to do element partly transparent;
Another difference between visibility:hidden and opacity:0 is that the element will still respond to events (like clicks) with opacity:0.

Friday, 16 August 2013

Argo - Themeforest Modern OnePage Metro UI Wordpress Theme

ARGO is a unique and creative Wordpress Theme with clean and modern design. It is perfect choice for your corporate agency, creative studio or for portfolio. It can be customized easily to suit your wishes.


Start – Metro UI Themeforest Responsive Admin Template

Start is a new responsive admin template based on latest Windows 8 interface. This one, called Metro UI, has its roots in the design principles of classic Swiss graphic design – minimal, bold, high contrast and flat colors are some of its great features.

Tuesday, 7 May 2013

What does “event bubbling” mean? [In context of CSS]

“Delegation” and “bubbling” are terms that gets thrown round a lot in JavaScript; but what exactly do these terms mean?

Event Bubbling

In JavaScript, events bubble. This means that an event propagates through the ancestors of the element the event fired on. Lets show what this means using the HTML markup below;
        <a href="#">
Lets assume we click the span, which causes a click event to be fired on the span; nothing revolutionary so far. However, the event then propagates (or bubbles) to the parent of the span (the <a>), and a click event is fired on that. This process repeats for the next parent (or ancestor) up to the document element.
You can see this in action here. Click “Hello” and see the events as they get fired.
That’s all event bubbling is; an event fired on an element bubbles through its ancestor chain (i.e. the event is also fired on those elements). It’s important to note that this isn’t a jQuery feature, nor is it something that a developer must turn on; it’s a fundamental part of JavaScript that has always existed.
Ok, that’s a little bit of a lie… sort of.
By default, not all events bubble. For instance submit does not normally bubble, nor does change. However, jQuery masks this in the event handling code using all sorts of voodoo, so it will seem that they do bubble when using jQuery.