jQuery代码正在谷歌浏览器,但不是Firefox,IE浏览器,甚至Safari浏览器 [英] jQuery Code is working on Google Chrome but not Firefox,IE and even Safari

查看:146
本文介绍了jQuery代码正在谷歌浏览器,但不是Firefox,IE浏览器,甚至Safari浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了这段代码,它在Google Chrome中运行良好,但是当涉及到Firefox和其他主流浏览器时,它甚至不会改变一点点:

  jQuery的( DIV [风格* = '行高:25像素'])的内容( :没有(节点类型= '1',BR))。包( < div style ='margin-bottom:9px; line-height:normal; margin-top:4px'>); 
jQuery(div [style * ='line-height:25px'] br)。remove();

看起来有点奇怪,但我想解决一个非常令人沮丧的问题,所以反正让我给你关于系统的规范:

$ ul

  • jQuery 1.3.2 with noConflict()方法避免与原型 $
  • 发生冲突
  • Scriptaculous 1.7.1_beta3

  • Prototype 1.5.1 使用 jQuery(document).ready()函数在DOM准备就绪后执行操作。



  • 这些库也嵌入在页面中。

    对于建议:
    我没有开发这个页面和其他几百页这样的问题是他们都是静态页面和使用 shtml

    感谢您的帮助。

    部分HTML:

     < div style =font-size:13px; line-height:25px; > 
    <! - BULLETS MORE - >
    < div style =line-height:normal;>
    优质全粒面卵石皮革
    < / div>
    平滑经典纳帕皮革建设
    < br />
    顶部访问的横向占位符
    < br />
    耐用皮带夹
    < br />
    带按扣的顶盖可增加安全性
    < br />
    柔软的天鹅绒衬里,带轻质保护层
    < br />
    底部的直通切口,便于摩托罗拉Droid的移除
    < br />
    简单的斯堪的纳维亚圆形设计
    < br />
    塞纳工艺和质量
    < br />
    < / div>


    解决方案

    b
    $ b

      jQuery(div)。filter(lineHeight).contents(nonElementNodes).wrap(< div style ='margin-bottom:9px ;行高:正常;边距:4像素'>中); 

    jQuery(div)。filter(lineHeight).find(br)。remove();

    函数lineHeight(){
    return this.style.lineHeight ==25px;


    function nonElementNodes(){
    return this.nodeType!== 1 || this.tagName!=='BR';
    }


    I wrote this code and it is working nicely in Google Chrome but when it comes to Firefox and other major browsers, it is not even changing a little bit thing :

    jQuery("div[style*='line-height:25px']").contents(":not(nodeType!='1',br)").wrap("<div style='margin-bottom:9px;line-height:normal;margin-top:4px'>");
    jQuery("div[style*='line-height:25px'] br").remove();
    

    It may look a bit weird but it is the thing I want to solve a really frustrating problem, so anyways let me give you the specifications about the system :

    • jQuery 1.3.2 with noConflict() method to avoid conflicts with prototype $
    • Scriptaculous 1.7.1_beta3
    • Prototype 1.5.1
    • And yeah I am using jQuery(document).ready() function to do things after DOM is ready.

    Those are the libraries also embedded on the page.

    For Recommendations: I didn't develop this page and other hundred of pages like this one and the problem is they are all static pages and using shtml to at least share some common code. But I can't remove any of those libraries because it means I will have to edit a lot of pages and it will cost me weeks. So actually what I am looking is temporary solutions like the one above.

    Thanks in advance.

    Partial HTML :

    <div style="font-size: 13px; line-height: 25px;">
      <!-- BULLETS MORE -->
      <div style="line-height: normal;">
        Fine quality, full grain pebble leather
      </div>
       Smooth Classic Napa leather construction
      <br />
       Lateral footprint with top access
      <br />
       Durable belt clip
      <br />
       Top flap with snap closure for added security
      <br />
       Soft velvet lining with light protective layer
      <br />
       Bottom push-through cutout for easy Motorola Droid removal
      <br />
       Simple Scandinavian rounded design
      <br />
       Sena craftsmanship and quality
      <br />
    </div>
    

    解决方案

    How about rewriting them slightly?

    jQuery("div").filter(lineHeight).contents(nonElementNodes).wrap("<div style='margin-bottom:9px;line-height:normal;margin-top:4px'>");
    
    jQuery("div").filter(lineHeight).find("br").remove();
    
    function lineHeight() {
      return this.style.lineHeight == "25px";
    }
    
    function nonElementNodes() {
      return this.nodeType !== 1 || this.tagName !== 'BR';
    }
    

    这篇关于jQuery代码正在谷歌浏览器,但不是Firefox,IE浏览器,甚至Safari浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆