JavaScript onclick()事件将不会执行

时间:2017-04-03 13:06:39

标签: javascript asp.net events model-view-controller onclick

我想在按下按钮时保存按钮的名称。 比我使用按钮名称显示模态并重定向到页面。

JavaScript的:

function onClickBtnRemove()
{
    deviceIdName = this.name;
}

function onClickBtnConfirmRemove() {
    window.location.href = "/Home/Remove/" + deviceIdName;    
}

HTML:

 <script> 
     var deviceIdName;
 </script>

<button class="btn btn-default" type="button" name="123" onclick="onClickBtnRemove()" data-toggle="modal" data-target="#remove" >
    <span class="glyphicon glyphicon-trash"></span>
</button>

<div class="modal fade" id="remove" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-body">
                <h4>Are you sure you want to remove this device?</h4>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary active" data-dismiss="modal" onclick="onClickBtnConfirmRemove()">Remove</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>

0 个答案:

没有答案