Q:

Find an element that contains a specified class using jquery

0

Find an element that contains a specified class using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Find an element that contains a specified class</title>
</head>
<body>
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
<style>
  .divclass {
    width: 90px;
    height: 75px;
    margin: 5px;
    background-color:#F3E2A9
  }
  </style>
</head>
<body>
<div id="div1" class="divclass"></div>
<div id="div2" </div>
<div id="div3" </div>  
 </body>
</html>

JavaScript Code :

console.log($( "#div1" ).hasClass( "divclass" ).toString());
console.log($( "#div2" ).hasClass( "divclass" ).toString());
console.log($( "#div3" ).hasClass( "divclass" ).toString());

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now