It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                7年前关闭。
            
        

回答了这个问题。但是stackoverflow不会让我问其他问题。有人可以帮忙吗?

最佳答案

声明s并将其默认设置为空字符串。如果q1不为空,则为分配一个值。否则s仍然是一个空字符串。在代码的更高版本中,您可以将文本框设置为填充s,如果q1为空,则s也将填充为s,因此此处将不显示任何内容。

//declare s and set it to default to an empty string
var s = ''
//make sure q1 is defined and not null
if (q1 != undefined && q1 != null)
   //if q1 is not empty, then set it equal to '_'+n1+'. '+q1,
   //otherwise s will be an empty string
   if (q1 != '')
       s = '_'+n1+'. '+q1
//if s is empty you can do something,
//OR you can just set your input value to equal s
if (s == '')
    //do some stuff here

09-19 11:03