Coder Social home page Coder Social logo

twns's People

Contributors

yyl0505 avatar gongmingqm10 avatar

Watchers

James Cloos avatar Liu Yang avatar  avatar

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.