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

jQuery .text() Method

0 votes
6 views
added Mar 30 in jQuery by LC Marshal First Warrant Officer (11,770 points)
edited Apr 6 by LC Marshal

Find element and get the text

var areaname = $('h1.page-header').text();

1 Response

0 votes
responded Mar 30 by LC Marshal First Warrant Officer (11,770 points)
edited Apr 6 by LC Marshal

If element has a text character > 30, do this. Else do this

$('.price.at-summary').each(function(){
  var text = $(this).text();
  if ( text.length > 31 ) {
    $('.calculator.at-summary').addClass('x-m-price').fadeIn(400);
  }
  else if ( text.length < 30 ) {
    $('.calculator.at-summary').addClass('r-m-price').fadeIn(400);
  } 
  else {
    $('.calculator.at-summary').fadeIn(400);
  }
});
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...