Add a custom attribute to the main div of a node only on teaser view mode I want to add a custom attribute to the main div of a node only on teaser view mode.
e-g

&lt;div class="node" tarbot="left"&gt; &lt;/div&gt;    


I need to add tarbot attribute to the main div of a node to apply a JS function. I want to affect only teaser view mode with my Function, not Full content display.
We can use preprocess function to change OR add an attribute to our node main div.

function MYMODULE_preprocess_node(&amp;$variables){

  // Array of aatributes which we want to pass to the node div.
  $attr_array = ['tarbot' =&gt; 'value']; 

  // Condition for teaser format.
  if ($variables['teaser'] == TRUE) { 

    $variables['attributes_array'] = $attr_array;   
  }
}


by using this function we will get our node div in this form

&lt;div class="node" tarbot="value"&gt; &lt;/div&gt;