如何在textarea中添加多行占位符文本?

时间:2016-05-25 12:59:40

标签: javascript jquery textarea placeholder

如何在textarea中添加多行占位符文本?

我得到了一个像下面这样的解决方案,但它不起作用我的苔藓,野生动物园。

Chrome以这种方式工作..

$('#nameTxtBox').attr("placeholder", "League Name \n 1-2 lines most designs");

2 个答案:

答案 0 :(得分:1)

不幸的是,不支持多行占位符作为规则。 Chrome确实允许换行符,但跨平台支持可能不稳定。建议的行动方案是创建更短的单行占位符。如果您绝对需要多行占位符,可以尝试:

rgb[:,:,j*3:(j+1)*3, i] = img

通过添加css属性public Character (String id,Position p); ,可以强制textarea将占位符文本视为预格式化文本。但是,支持是不稳定的。

答案 1 :(得分:0)

尝试此代码

只需在新行前添加“ &#10 ”即可。

[CmdletBinding(SupportsShouldProcess=$true)]
 param(
    [string]$NewLocation.GetType($ElasticSearch)
    [string]$ElasticSearch = "C:\Elastic_Test_Server\elasticsearch\bin"
    [string]$Kibana = "C:\Elastic_Test_Server\kibana\bin"
    [string]$Logstash = "C:\Elastic_Test_Server\logstash\bin"
    )
 Begin
 {

    #Je potřeba spustit jako Administrátor

     $regPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
     $hklm = [Microsoft.Win32.Registry]::LocalMachine

     Function GetOldPath()
     {
         $regKey = $hklm.OpenSubKey($regPath, $FALSE)
         $envpath = $regKey.GetValue("Path", "", [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
         return $envPath
     }
 }

 Process
 {


     # Win32API errory
     $ERROR_SUCCESS = 0 
     $ERROR_DUP_NAME = 34
     $ERROR_INVALID_DATA = 13

     $NewLocation = $NewLocation.Trim();

     If ($NewLocation -eq "" -or $NewLocation -eq $null)
     {
         Exit $ERROR_INVALID_DATA
     }

     [string]$oldPath = GetOldPath
     Write-Verbose "Old Path: $oldPath"

     # Zkontroluje zda cesta již existuje
     $parts = $oldPath.split(";")
     If ($parts -contains $NewLocation)
     {
         Write-Warning "The new location is already in the path"
         Exit $ERROR_DUP_NAME
     }

     # Nová cesta
     $newPath = $oldPath + ";" + $NewLocation
     $newPath = $newPath -replace ";;",""

     if ($pscmdlet.ShouldProcess("%Path%", "Add $NewLocation")){

         # Přidá to přítomné session
         $env:path += ";$NewLocation"

         # Uloží do registru
         $regKey = $hklm.OpenSubKey($regPath, $True)
         $regKey.SetValue("Path", $newPath, [Microsoft.Win32.RegistryValueKind]::ExpandString)
         Write-Output "The operation completed successfully."
     }

     Exit $ERROR_SUCCESS
 }