jQuery Syntax

0 votes
228 views
added Apr 5, 2018 in jQuery by LC Marshal Captain (25,790 points)

Example 1.

$(function() {
  var expiry = $('span.expiry_msg');  
  if ($(expiry).length) { 
   $(expiry).clone().appendTo('#footer > span.expiry-msg').addClass('footer-expiry').fadeIn(500);
  }
});
$(function() { ... });

is just jQuery short-hand for

$(document).ready(function() { ... });

1 Response

0 votes
responded May 16, 2018 by LC Marshal Captain (25,790 points)

to apply same method to more than 1 variables

var viewQ = $('.tabs--primary.nav.nav-tabs li:first-child'),
    commentTitle = $('#comment-body-add-more-wrapper label.control-label'),
    editPreview = $('#edit-preview');

viewQ.add(commentTitle).add(editPreview).hide();
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...