admin管理员组文章数量:1208155
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.
the id of the artist input field is #request_artist
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.
the id of the artist input field is #request_artist
Share Improve this question asked Sep 19, 2010 at 14:35 Matt ElhotibyMatt Elhotiby 44.1k91 gold badges224 silver badges328 bronze badges 1- External links can break. Please let your question be self contained – lilalinux Commented Feb 25, 2016 at 10:56
3 Answers
Reset to default 12You can do something like this:
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);
}
});
for the input field, the submit button should be equal $('#request_artist').attr('disabled', true);
The one liner code would be :
<input type="text" name="name" value="" id="txt1" />
<input type="button" name="name" id="btn1" disabled="disabled" value="Submit" />
<script type="text/javascript">
$("#txt1").keyup(function () {
$("#btn1").attr("disabled", $.trim($("#txt1").val()) != "" ? "" : "disabled");
});
</script>
本文标签: javascriptHow do i grey out the input field and the submit buttonStack Overflow
版权声明:本文标题:javascript - How do i grey out the input field and the submit button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738687534a2106907.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论