如何在出现提示之前隐藏div

时间:2019-07-04 22:22:18

标签: javascript html

单击button会在title出现之前隐藏prompt dialog,而不是之后隐藏。

该怎么做?

$('button').on('click', function(){
    let a = $('#title').text();
    $('#title').hide();
    let res = prompt('RENAME', a);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>CLICK</button>
<br>
<div class='title' id='title'>lorem ipsum</div>

1 个答案:

答案 0 :(得分:1)

您可以使用回调

 private Client newClientRow()
    {
        var clients = new ObservableCollection<Client>();

        var client = new Client
        {
            clientID = -1,
            clientName = "New Client",
            clientEmail = "f",
            add1 = "f",
            add2 = "R",
            add3 = "l",
            add4 = "F",
            postcode = "f",
            telephoneNumber = "01244"
        };
        return client;
    }
 public ObservableCollection<Client> Source
    {
        get
        {   
            daClient daClient = new daClient();
            ObservableCollection<Client> clients = new ObservableCollection<Client>(daClient.GetClients((Application.Current as App).ConnectionString))
            {
                //This works the same as using clients.Add(newClientRow()); - just put it inside the curly bracked when initializing the ObservableCollection. 
                newClientRow()
            };
            return clients;
        }
    }