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
35 views
added Apr 2 in jQuery by LC Marshal Lieutenant (14,830 points)
retagged Sep 21 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();
  } 
});

4 Responses

0 votes
responded Apr 2 by LC Marshal Lieutenant (14,830 points)
edited Apr 11 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 by LC Marshal Lieutenant (14,830 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 by LC Marshal Lieutenant (14,830 points)
edited Sep 21 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 by LC Marshal Lieutenant (14,830 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>'); 
  } 
});

 

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