twns's People
twns's Issues
问题原因和解决方案
button按钮的 disable 属性
首先,解释一下button的 disable 属性。一个button在显示的时候,有是否可以被点击的属性,参考(http://www.w3school.com.cn/tags/att_button_disabled.asp)。 所以你更改按钮的 disable属性并不会让它出现或者消失。
Jquery 中的 hide 和 show 方法
所以,如果你想隐藏一个元素的话,可以使用Jquery框架中的hide和show方法。它会修改一个dom元素的display属性,以此来完成显示或者消失效果。
参考:
hide方法:http://api.jquery.com/hide/
show方法:http://api.jquery.com/show/
解决方案
所以我更改了两个函数,让网页正常工作
$(document).ready(function(){
dataToView(disks);
$('.disk1').mouseenter(function(){
$('#'+this.id+' > button').show();
/* $('#'+this.id+' > button').removeAttr('disabled'); 不是更改disable属性*/
})
.mouseleave(function(){
$('#'+this.id+' > button').hide();
/*$('#'+this.id+' > button').attr('disabled', 'true');*/
});
$('.disk1 > button').click(function(){
var start=parseInt(this.id.charAt(this.id.length-1));
disks.splice(start-1, 1);
dataToView(disks);
});
});
function diskBtn()
{
var id='btn'+divNums;
return $('<button>').html('delete')
.attr('id', id).hide(); /* 所以在初始状态下是隐藏的 */
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.