2017-08-24 34 views
0

我已经使用道具jQuery语法启用我的保存按钮并禁用编辑按钮后点击编辑按钮的事件,我不知道为什么它是不可见的,而不是启用保存按钮。prop()隐藏我的按钮,而不是禁用

$(document).ready(function() { 
 
    $('#saveProject').click(function() { 
 
    $('#editProject').prop("disabled", false); 
 
    $('#saveProject').prop("disabled", true); 
 
    $('.fields').prop("disabled", true); 
 
    $('.fields').css({ 
 
     "border-bottom": "4px solid teal" 
 
    }); 
 
    }); 
 

 
    $('#editProject').click(function() { 
 
    $('#saveProject').prop("disabled", false); 
 
    $('.fields').prop("disabled", false); 
 
    $('.green').css({ 
 
     "border-bottom": "4px solid green" 
 
    }); 
 
    $('.red').css({ 
 
     "border-bottom": "4px solid red" 
 
    }); 
 
    $('#editProject').prop("disabled", true); 
 
    }); 
 

 
    $('#clearProject').click(function() { 
 
    $('#clearProject').prop("disabled", false); 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="w3-red"> 
 
    <input id="saveProject" type="submit" class="w3-button w3-right w3-col m3" style="background-color:#030066;" value="Save Project" disabled="disabled"> 
 
    <input id="editProject" class="w3-button w3-right w3-rightbar w3-col m2" style="background-color:#030066;" value="Edit"> 
 
    <input id="clearProject" class="w3-button w3-right w3-rightbar w3-col m4" style="background-color:#030066;" value="Default Values" type="reset"> 
 
</div>

+0

你可能有一个类型的错误'$( '#saveProject.visible')'应该是不是'$('#saveProject:visible')' –

+0

不,这不是我刚刚试验过的实际语法。可见在那里,当我尝试你的方式..仍然没有任何反应 –

+0

*“我不知道为什么它是不可见的,而不是启用保存按钮。”*什么? 0_0 – zer00ne

回答

0

CSS修复

.w3-button { 
    background-color: #030066; 
    color: #fff; 
    cursor: pointer; 
} 

.w3-button[disabled] { 
    background-color: #eee; 
    color: #888; 
    cursor: not-allowed !important; 
} 

和HTML

<input id="editProject" class="w3-button w3-right w3-rightbar w3-col m2" value="Edit" 
type="button">