Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery .length property

0 votes
40 views
added Apr 2, 2018 in jQuery by LC Marshal Lieutenant (18,350 points)
retagged Sep 21, 2018 by LC Marshal

To check whether elemet exist by .length

$('body').each(function() {
  var expiredprop = $('span.expiry_msg').text();
  if (expiredprop.length > 1) {
    $('#contact-agent-topbar').hide();
  } 
});

5 Responses

0 votes
responded Apr 2, 2018 by LC Marshal Lieutenant (18,350 points)
edited Apr 11, 2018 by LC Marshal

.length() property type

$('span.expiry_msg').length; 

if (expiredprop.length > 1) {
  $('#element').hide();
}  

if ($(expiry).length) { 
  // do this
}
0 votes
responded Apr 5, 2018 by LC Marshal Lieutenant (18,350 points)

if the expiry message is exist on the body, do this.

$(function() {
  var expiry = $('span.expiry_msg');  
  if ($(expiry).length) { 
   $(expiry).clone().appendTo('#footer > span.expiry-msg').addClass('footer-expiry').fadeIn(500);
  }
});
0 votes
responded Apr 11, 2018 by LC Marshal Lieutenant (18,350 points)
edited Sep 21, 2018 by LC Marshal

If element height is lesser than 1800, .hide() read-more, else .show()

$('body.page-property-detail').each(function() {
  var propDetailContent = $('.page-property-detail .listing-expandable').text();
  var pdtrimcontent = $.trim(propDetailContent);
  if(pdtrimcontent.length < 1800) {
    // alert('hey!');
    $('.readmore.font-sans').hide();
  }
  else {
    $('.readmore.font-sans').show();
  }
});
0 votes
responded Sep 21, 2018 by LC Marshal Lieutenant (18,350 points)
//when text is not exist, do this

$('body.page-my-all-units').each(function() {
  var historyList = $('.row.portfolio-account-history .control-label').text(); 
  if (historyList.length < 1) {
      $('.view-filters').hide();
      $('.view.view-all-transactions-block').html('<span>No activities so far</span>'); 
  } 
});

 

0 votes
responded 4 days ago by LC Marshal Lieutenant (18,350 points)
if ($('.skin-ads').length) {
  $('.new-theme').css({'top': '300px', 'margin-bottom': '300px', 'transition': 'all .5s .2s ease-in-out'});
} 

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...