2015-04-06 21 views
-1

我有這樣的代碼:添加JavaScript事件中的DropDownList HTTP幫手ASP.NET MVC

<div class="col-xs-6 col-sm-3"> 
     @Html.DropDownList("cssFiles", (IEnumerable<SelectListItem>)ViewBag.cssFiles, "Crear Nuevo", new { @class = "form-control", @id = "selCssFile" }) 
     <span> 
      <input type="text" class="form-control" id="txtFileName" style="display:none;" placeholder="Nombre del archivo"> 
     </span> 
</div> 

我要爲節目添加JavaScript事件「txtFileName」當「CREAR NUEVO」是選擇和隱藏當下拉更改

+0

你可以做到這一點與jQuery的。 – ataravati

回答

2

基本上,您需要在您的下拉元素上附加單擊事件。

代碼

$('#selCssFile').on('change',function(){ 
    //implement code after selected the option 
});