Get element by ClassName with starts with a certain string - Javascript DOM

Javascript examples for DOM:Document querySelectorAll

Description

Get element by ClassName with starts with a certain string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w w  w  . j  a  va 2 s . c o  m
var x = window.document.querySelectorAll("*[class^=\"width-48 height-48 profile_view_img\"]")[0]
console.log(x.className);
    }

      </script> 
   </head> 
   <body> 
      <span class="width-48 height-48 profile_view_img_473"></span>  
   </body>
</html>

Related Tutorials