Yii2: Assigning javascript event to anchor tag in yii2

徘徊边缘 提交于 2019-12-11 12:16:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!