jQuery show submit button on input field click

Posted by Pjack on Stack Overflow See other posts from Stack Overflow or by Pjack
Published on 2010-05-04T15:07:53Z Indexed on 2010/05/04 16:08 UTC
Read the original article Hit count: 244

Hi,

I'm trying to have a comment input field that will show the submit button on a dynamically created form when you click on the input field. Similar to how facebook comments work. When you click on the input field the submit button appears and when you click off it disappears. All the comment input id's are comment_1 etc and the submit button id's are submit_1 etc.

I've tried this,

jQuery("#[id^='comment_']").live('click',function(event){ 
    if(jQuery("#[id^='comment_']").val() == ""){ 
        jQuery("#[id^='submit_']").hide(); 
    } 
    else { 
        jQuery("#[id^='submit_']").show(); 
    } 
}); 

And that won't work for some reason. Any suggestion or how it can be accomplished would be great.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript