【问题标题】:How do i make something inside .html() clickable?如何使 .html() 中的内容可点击?
【发布时间】:2016-01-06 20:57:28
【问题描述】:

我正在尝试使“项目 1”成为一个链接。将不胜感激。

   $(document).on('pagecontainerbeforehide','body', function(event, ui){ 
    if (ui.nextPage.attr('id') == "bookmarks"){

        if( $("#bookmark1").is(":checked")){ 

            $("#bookmark-content").html("item 1 ");

        }

【问题讨论】:

    标签: jquery jquery-ui jquery-mobile


    【解决方案1】:

    用标签包围它(<span> 可以),然后。

    $("#bookmark-content").find(elementSelectorYouJustCreated).on('click', function(e){ /*do stuff*/ });
    

    或者您可以保存查找...

    if( $("#bookmark1").is(":checked")){
        var $item1 = $('<span>').text("item 1 ");
        $item1.on('click', function(e){ /*do stuff*/ });
        $("#bookmark-content").empty().append($item1);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      相关资源
      最近更新 更多