假的CSS:只有孩子在IE8与jQuery / JavaScript [英] Faking CSS :only-child in IE8 with jQuery/JavaScript
问题描述
我有一个带有:only-child选择器的菜单,以便我可以指示子菜单。后选择器工作在IE8(唯一的旧IE版本,我不得不支持),但是:only-child选择器不,所以我得到一个箭头在每个菜单项,不只是有子菜单。
I have a menu with the :only-child selector so that I can indicate submenus. The :after selector works in IE8 (the only old IE version I have to support), but the :only-child selector does not, so I get an arrow on every menu item, not just on the ones with a submenu.
.menu li > a:after { content: ' ▾'; }
.menu li > a:only-child:after { content: ''; }
我想要的是使用jQuery或JavaScript实现。 我不想使用Modernizr或Selectivizr和所有的东西,只需一个代码作为唯一的孩子的替代。
What I want is to achieve this using jQuery or JavaScript. I don't want to use Modernizr or Selectivizr and all that stuff, just a single code as an alternative to only-child.
我真的会喜欢,如果你能帮助我。我是一个新手,当谈到jQuery和JavaScript,所以请解释彻底。谢谢!
I would really appreciate if you could help me out. I am a newbie when it comes to jQuery and JavaScript, so please explain thoroughly. Thanks!
推荐答案
对于其他人想知道这个问题,并且有相同的问题没有得到@ BoltClock的代码工作,如果将 $
更改为 jQuery
,如下所示:
For others wondering about this and have the same problem not getting @BoltClock's code to work, it will most probably work if you change $
to jQuery
, like this:
jQuery("SELECTOR").exampleMethod("EXAMPLESTRING");
这篇关于假的CSS:只有孩子在IE8与jQuery / JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!