English 中文(简体)
是否能够对位于盖尔斯的文字进行现场检测?
原标题:Is it possible to perform live detection of text typed into textarea in JQuery?

我有一个“邮政”纽芬兰语,在文本被打入文字区时,可以激活(从蓝色到颜色,从残疾到残疾)。

This works fine but I would like the text area to detect when there is nothing in the text area. So let s say I typed "abc" into the text area.. the submit button would become active but let s say I now delete all the text.. The button is still active.. well not fully as I have this:

commentButton.prop({ disabled: commentBox.val() == 0 });

不能在案文中提交任何内容。 问题是,提交国仍然有颜色,没有回到表面上不活跃的国家。

因此,我要谈谈我的问题。

Can I set up something that will activate and start listening as soon as i focus in the text area and type and know when I ve deleted everything from the text area?

这样,我就可以说,如果案文全部删除,那么就删除了彩色邦纽顿的地图集,并添加模糊邦纽顿的地图集。

这也适用于白人空间。

我目前的法典是:

www.un.org/Depts/DGACM/index_french.htm

.activeCommentButton = coloured submit button

.commentButton = blurred submission button

$(".microposts").off().on("focus", ".comment_box", function () {
    $(this).prop("rows", 7);
    $(this).parent().find(".activeCommentButton").removeClass("activeCommentButton").addClass("commentButton");
    var commentBox = $(this),
        form = $(this).parent(),
        cancelButton = form.children(".commentButtons").children(".cancelButton"),
        commentButton = form.children(".commentButtons").children(".commentButton");
    $(this).removeClass("comment_box").addClass("comment_box_focused").autoResize();
    form.children(".commentButtons").addClass("displayButtons");
    commentButton.prop({
        disabled: true
    });
    commentBox.off().on("keyup keypress input change", function () {
        commentButton.prop({
            disabled: commentBox.val() == 0
        });
        commentButton.removeClass("commentButton").addClass("activeCommentButton");
    });
    cancelButton.click(function () {
        commentBox.removeClass("comment_box_focused").addClass("comment_box");
        form.children(".commentButtons").removeClass("displayButtons");
        commentBox.val("");
    });
});

幼儿园

最佳回答

是的,你可以修改:

$(".commentButton").prop({ disabled: true });

$(".comment_box").keypress(function() {

    $(".commentButton").prop({ disabled: !$(this).val().length >= 1 })           

});
问题回答

这对我来说是行之有效的,但是否采取了更清洁的方法?

 commentButton.prop({ disabled: true });

                commentBox.off().on("keyup keypress input change", function () {
                  commentButton.prop({ disabled: commentBox.val().length == 0 });
                  if ( commentBox.val().length > 1 ) {
                  commentButton.removeClass("commentButton").addClass("activeCommentButton");
              } else {
                commentButton.removeClass("activeCommentButton").addClass("commentButton");
              }
                });




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签