Tutorialsplane

Get element by class name in AngularJs


Get element by class name in AngularJs : It is very common to deal with class and id selector in AngularJs. You can use AngularJs jQuery lite to get all elements by class name. Here in this tutorial we are going to explain how to use jQlite to get element by class name. You can also use our online tool to run and edit the code.


How to Get element by class name in AngularJs?

You can use jQlite angular.element() to get the element by class name. Let us go step by step.

JavaScript Part –

JavaScript Part Contains the following script –

Get element by class name in AngularJs : JavaScript

  

Html Part-

Html Part Contains the following html –

Get element by class name in AngularJs Example:

<div ng-app="myApp">  
<div ng-controller="myController">  
<h3>AngularJs Is Cool!</h3>
<p class="myPara">
This is test paragraph....
</p>
 
</div> 

</div>

Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

Get element by class name in AngularJs:




 
 




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
<h3>AngularJs Is Cool!</h3>
<p class="myPara">
This is test paragraph....
</p>
 
</div> 

  


</div>

Try it »

If you run the above example it will produce output something like this –