匹配整个文档的第一个元素? [英] Matching first element in whole document?
本文介绍了匹配整个文档的第一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想匹配整个文档中的第一个H1元素。不过,现在我面临的一个问题。
I want to match the first H1 element in my whole document. However, right now I'm faced with a problem.
我用下面的CSS选择器:
I'm using the following CSS selector:
h1:first-child {
...
}
但是,它匹配页面上的几个H1标记。我怎样才能使它只匹配第一个?
However, it matches several H1 tags on the page. How can I make it match only the first one?
推荐答案
您允许使用jQuery作弊?某些时候的jQuery(JavaScript的)提供(S)超出了HTML和CSS的局限性优雅的替代品
are you allowed to cheat with jQuery? some times jQuery (javascript) provide(s) elegant alternatives beyond the html and css limitations
$(document).ready(function() {
$('body').find('h1:first').css('color','#0000ff');
}); // ready
这篇关于匹配整个文档的第一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文