CSS: How make the cursor to become a pointer on the input file?

后端 未结 6 747
时光取名叫无心
时光取名叫无心 2021-01-06 03:25

How can I make the cursor to become a pointer on an input file or an input text when you hover it?

My try but it does not work of course,



        
6条回答
  •  长情又很酷
    2021-01-06 04:11

    You can do this ugly jQuery hack:

    $('input:file').each(function(){
        var $input = $(this);
        $input.before($('
    ').height($input.height()).width($input.width()).css( { cursor: 'pointer', position: 'absolute', zIndex: $input.css('z-index') }).click(function(){ $(this).hide(); $input.click(); $(this).show(); })); });

    But it prevents the animation you normally see when you mousedown on a button element. JSFiddle

提交回复
热议问题