onClick attribute striped out in rendered html I have below code in my Form. But after rendering i could not see the onClick attribute in the link. 

$form['step2_submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Next'),
    '#prefix' =&gt; '&lt;div class="left"&gt;&lt;a onClick="javascript:back_callback(1);" href="javascript:void(0)" class="back_btn"&gt;'.t('Back').'&lt;/a&gt;&lt;/div&gt;&lt;div class="right"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#name' =&gt; 'step2',
    '#attributes' =&gt; array('class' =&gt; array('enabled-for-ajax')),
    '#ajax' =&gt; array(
                'callback' =&gt; '::myajaxmethod',
              )
);


But i got the below output, without onClick attribute and javascript: in the output. 

&lt;div class="left"&gt;&lt;a class="back_btn" href="void(0)"&gt;Back&lt;/a&gt;&lt;/div&gt;


Is this restricted? If so, how to achieve this in drupal 8?
Try this code:
$form['cancel'] = [
  '#markup' =&gt; '&lt;div class=&quot;left&quot;&gt;&lt;a onClick=&quot;javascript:back_callback(1);&quot; href=&quot;javascript:void(0)&quot; class=&quot;back_btn&quot;&gt;' . t('Back') . '&lt;/a&gt;&lt;/div&gt;',
];
$form['step2_submit'] = [
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Next'),
  '#prefix' =&gt; '&lt;div class=&quot;right&quot;&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#name' =&gt; 'step2',
  '#attributes' =&gt; ['class' =&gt; ['enabled-for-ajax']],
  '#ajax' =&gt; [
    'callback' =&gt; '::myajaxmethod',
  ],
];