YII注册JS-->动态添加文本框
<?php \Yii::$app->view->registerJs(<<<JS $("img#add_new_column").bind( "click",function(){ $("div#add_column:last").append("<div id=\"add_column\"><input style=\"width:240px;float:left;margin-right:20px;\" type=\"text\" id=\"goods-customize_01\" class=\"form-control\" name=\"Goods[customize_01][]\" placeholder=\"例:颜 色:\"><input style=\"width:540px;\" type=\"text\" id=\"goods-customize_01\" class=\"form-control\" name=\"Goods[customize_01][]\" placeholder=\"例:黄,白,蓝\"><div class=\"help-block\"></div></div>"); } ); $("img#reduce_column").bind( "click",function(){ $("div#add_column:last").remove(); } ); JS , 4); ?>