问题
how to assign javascript onclick event to the anchor tag what is the mapping of it in yii2
<a style="margin-left: 30px;" href="" onclick="$('#createTeamForm').show(500); $('#createTeamForm').css('display','')"> Create Team</a>
回答1:
You can achieve this like below:
\yii\helpers\Html::a('Create Team',\yii\helpers\Url::to('url'),['onclick'=>"$('#createTeamForm').show(500);$('#createTeamForm').css('display','')",'style'=>'margin-left: 30px;']);
来源:https://stackoverflow.com/questions/27356300/yii2-assigning-javascript-event-to-anchor-tag-in-yii2