# How to get html css class from a element name ??

**URL:** <https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316>\
**Category:** Classic Servoy\
**Created:** [June 21, 2017, 7:59am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316 "2017-06-21T07:59:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashutoslenka426](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@ashutoslenka426](https://forum.servoy.com/u/ashutoslenka426)\
**Post date:** [June 21, 2017, 7:59am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/1 "2017-06-21T07:59:31Z")

</div>

Hi All ,

Suppose I have created a button component . Dragged onto the form . I know the elements name . How can I know the css class name or id where it is rendered ? .

I required this for other component target specification.

Please provide your suggestions

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 21, 2017, 8:14am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/2 "2017-06-21T08:14:30Z")

</div>

You want to know this in the browser or in scripting?

---

<div class="post-metadata">

**Author:** ![ashutoslenka426](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@ashutoslenka426](https://forum.servoy.com/u/ashutoslenka426)\
**Post date:** [June 21, 2017, 8:16am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/3 "2017-06-21T08:16:16Z")

</div>

Hi ,

Thanks for your reply . I want this either in the component js or servoy js. But how this possible ?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [June 21, 2017, 10:02am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/4 "2017-06-21T10:02:41Z")

</div>

The model object in the client js has a svyMarkupId property which you can use to assign an ID to your component (something like \< … id=“{{::model.svyMarkupId}}” … \>. That allows you to deal with an ID in your component html.

The style classes can be retrieved from the element that you receive in your controller or link function.

---

<div class="post-metadata">

**Author:** ![ashutoslenka426](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@ashutoslenka426](https://forum.servoy.com/u/ashutoslenka426)\
**Post date:** [June 21, 2017, 11:14am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/5 "2017-06-21T11:14:25Z")

</div>

Hi Patrick ,

Thanks for your reply . I got your point . But I have two components - Button and contextmenu . I want to access button Markup Id in Context Menu . When I am hardcoding it is fine . But how to access it dynamically ? . How this is possible ?

Button HTMl :

```auto
<div class="bts-button" id="{{::model.svyMarkupId}}" dx-button="ButtonOptions" 
svy-click='handlers.onActionMethodID($event)' 
svy-dblclick='handlers.onDoubleClickMethodID($event)' 
svy-rightclick='handlers.onRightClickMethodID($event)'
sablo-tabseq='model.tabSeq'
 ng-if="model.visible" ng-class="model.styleClass">
</div>

```

Context Menu Js :

```auto
$scope.api.show = function() {
    		
			  $scope.contextMenuOptions = {
	    		  
	    		  dataSource: contextMenuItems,
	    		    width: 200,
	    		    position: {
	    		        
	    		       
	    		    }, 
	    		  
			        target:"#" + "3c30fc1c75040391183fcf65f0e058e9",
					onItemClick: function(e){
						if (!e.itemData.items) {
				        	DevExpress.ui.notify("The \"" + e.itemData.text + "\" item was clicked", "success", 1500);
				        	$scope.handlers.onActionMethodID(e.itemData.text);
				        }
				    }
							    
	    	  }	
		  }

```

Servoy JS :

```auto
elements.Context_Menu_1.show(elements.Button_2);

```

Please provide your suggestion

---

<div class="post-metadata">

**Author:** ![ashutoslenka426](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@ashutoslenka426](https://forum.servoy.com/u/ashutoslenka426)\
**Post date:** [June 22, 2017, 4:01am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/6 "2017-06-22T04:01:45Z")

</div>

Please provide some suggestions .

---

<div class="post-metadata">

**Author:** ![ashutoslenka426](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@ashutoslenka426](https://forum.servoy.com/u/ashutoslenka426)\
**Post date:** [June 22, 2017, 4:55am UTC](https://forum.servoy.com/t/how-to-get-html-css-class-from-a-element-name/19316/7 "2017-06-22T04:55:41Z")

</div>

Thanks Solved . I did that using api call.
