• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jQuery 和 iOS 设备

[复制链接]
菜鸟教程小白 发表于 2022-12-13 05:38:17 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我有 html 格式的纯文本。我将类添加到某些标签以使用 jQuery 即时格式化它们。

在 PC 和 Android 上一切正常,但在 iOS 上没有任何反应。可能是什么错误?

示例代码如下

<script>
var $=jQuery.noConflict();
jQuery( document ).ready(function() { 
    var dialog = $( "p:has(strong)" ).addClass( "wi-dialog" );
    var chapter = $( "p:has(ins)" ).addClass( "wi-chapter" );
    dialog.html(function(i, v) { return v.replace(/(?<=\n)\s*(\(.*?\)).*?/g, '<span class="wi-remark">$&</span>') });

    var more = $(".wi-remark:contains(MORE)").addClass( "wi-more").removeClass( "wi-remark");

    var p = $('p:not(.wi-dialog,.wi-chapter)');
    p.filter(function() { 
        return ((/^[0-9.]+$/).test($(this).html())); 
    }).addClass("wi-number");
    p.filter(function() {
        return ((/^(THE END)+$/).test($(this).html())); }).addClass( "wi-end" );
    });
});
</script>

问题来了

dialog.html(function(i, v) { return v.replace(/(?<=\n)\s*(\(.*?\)).*?/g, '<span class="wi-remark">$&</span>') });

文本示例

<p><strong>HENRY</strong>
Gather more wood.</p>

<p>Fitzgerald waits for Henry to turn, then gives his back an exaggerated salute.</p>

<p><strong>FITZGERALD</strong><br>
(under his breath)<br>
Shame my Pap was a broken down drunk. Else he could’ve bought me a Captain’s job too.</p>

<p>Boone snickers. Fitzgerald stomps his boot onto a branch, easily snaps it into two easy-to-carry pieces.</p>

<p><strong>FITZGERALD</strong> (CONT’D)<br>
We got a plan for these fires, Captain, or are we roastin’ berries all the way up to Fort Union?</p>

<p><strong>HENRY</strong><br>
Glass and the others will be back with some game, Fitzgerald. Just make sure you have the fires ready.</p>

<p><strong>FITZGERALD</strong><br>
My supper’s in the hands of a injun- lover, a peach-fuzz kid and a half- wit dummy. Hell, my belly feels full already.</p>



Best Answer-推荐答案


此解决方案应该适合您。问题是负面的后视,这在某些 iOS 版本上不起作用。现在它正在使用非捕获组。


 


						

关于jQuery 和 iOS 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57728760/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap