gpt4 book ai didi

jquery - js 函数生成 href 以包含数据角色 ="button"

转载 作者:行者123 更新时间:2023-12-01 01:18:39 26 4
gpt4 key购买 nike

我下面有一个 JS 函数,它生成一个 href,其中包含 JQ Mobile data-role="button"类。浏览器忽略了这一点 - 任何人都可以提出解决方案。

<script>  
function showCONTACTDETAIL() {

var tryouttext='<a href="" data-role="button">hey this is cool</a>';
jQuery('#tryout').html(tryouttext);

}
$('#cusdetail').live('pageshow', function () { showCONTACTDETAIL(); });
</script>

最佳答案

使用

jQuery('#tryout').html(tryouttext).trigger( "create" );

您需要触发容器上的 create 事件,以使该容器中的所有动态内容都获得样式。

<小时/>

引用自http://jquerymobile.com/blog/2011/07/22/jquery-mobile-team-update-week-of-july-18th/

Now, our handy create event will initialize all the necessary plugins within that markup, just like how the page creation enhancement process works. If you were to use Ajax to load in a block of HTML markup (say a login form), you can trigger create to automatically transform all the widgets it contains (inputs and buttons in this case) into the enhanced versions.

关于jquery - js 函数生成 href 以包含数据角色 ="button",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7796276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com