簡體   English   中英

強制顯示元素的“標題”屬性並保持可見,直到另行通知

[英]Force display of 'title' attribute of element and keep visible until further notice

我想使用title屬性存儲我的驗證消息。我當前正在將ketchup用於我們的驗證庫。 我們嘗試了其他插件,但是喜歡番茄醬的功能。 我想觸發錯誤,並顯示標題屬性,直到錯誤得到糾正。 有沒有一種方法可以使標題屬性在元素上保持打開狀態,即使用戶離開元素時也是如此,直到更正驗證為止。

不能。您無法控制瀏覽器的工具提示處理。 您將需要使用其他方法來顯示錯誤。

我不知道為什么工具提示在這里不起作用,但是我已經測試過它可以正常工作。

 $("#submit").click(function(){ if($("#name").val().length < 3) { $("#name").tooltip('show'); } }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <input type="text" title="Your name" id="name"> <button type="button" id="submit">Submit</button> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM