Javascript examples for jQuery Method and Property:text
Check <p> value in jquery
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> <script type="text/javascript"> window.onload=function(){//from www .j a v a 2s. c o m var pContents = $('p').text(); var result; if (pContents.trim() === 'The content') { result = "test!"; } else { result = "no!"; } $('span').html(result); } </script> </head> <body> <p> The content </p> <span></span> </body> </html>