javascript 使用 jquery click() 打开弹出页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17130643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 07:11:01  来源:igfitidea点击:

Open popup page using jquery click()

javascriptjquery-mobilepopup

提问by Zakki Alawi

I want to open or show up popup page using java script in input text :

我想在输入文本中使用 java 脚本打开或显示弹出页面:

<input class="addpopup" type="text" name="address" id="address"></input>
<script>
    $(".addpopup").click(function () {
        $(this).page('#popupAddfix');
    });
</script>

And popup code :

和弹出代码:

<div data-role="popup" id="popupAddfix">
  <form>
    <h3>Your Address</h3>
    <label >Address</label>
    <input type="text" name="addfix" id="fix" value=""/>

    <button type="submit" >Save</button>
  </form>
</div>

But it is not opening a popup. How do I make this happen ?

但它没有打开弹出窗口。我该如何做到这一点?

回答by Omar

To open popup programmatically, you need to call it using .popup('open'). Using any event, e.g. focus, click, tap...etc

要以编程方式打开弹出窗口,您需要使用.popup('open'). 使用任何事件,例如focus, click, tap... 等

Demo

演示

$(document).on('focus', '.addpopup', function() {
 $('#popupAddfix').popup('open');
});