如何使输入字段和提交按钮变灰 [英] How do i grey out the input field and the submit button

查看:97
本文介绍了如何使输入字段和提交按钮变灰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将这两件事变为歌曲输入字段和提交按钮,直到用户输入和艺术家。有没有一种简单的方法可以通过JQuery来做到这一点。

I want to grey out these two things the song input field and the submit button until the user enters and artist. Is there an easy way to do this via JQuery.

艺术家输入字段的id是#request_artist

the id of the artist input field is #request_artist

推荐答案

你可以这样做:

var artist = ('#request_artist');
var song = ('#request_song');
var assubmit = ('#request_submit');

song.attr('disabled', true);
assubmit.attr('disabled', true);

artist.change(function() {
  if(artist.val() > 0) {
    song.attr('disabled', false);
    assubmit.attr('disabled', false);
  } else {
    song.attr('disabled', true);
    assubmit.attr('disabled', true);
  }
});

这篇关于如何使输入字段和提交按钮变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆