小编M K*_*M K的帖子

如果div不存在,你可以在CSS中应用CSS规则吗?

这有可能,用CSS吗?

如果.div1不存在,请应用此规则:

.div2{
  property: value;  
}
Run Code Online (Sandbox Code Playgroud)

喜欢

<div class="div1">
...
</div>

<div class="div2">
 <!-- it exists, so do nothing -->
</div>
Run Code Online (Sandbox Code Playgroud)

<div class="div2">
 <!-- it doesn't exist, apply the css -->
</div>
Run Code Online (Sandbox Code Playgroud)

html css css-selectors

12
推荐指数
3
解决办法
2万
查看次数

如何将jquery对象传递给history.pushState

var data = { url: $(this).attr('href'), selector: $(this) };
history.pushState(data, 'foo', $(this).attr('href'));
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我收到一个错误:

组件返回失败代码:0x8000ffff(NS_ERROR_UNEXPECTED)[nsIDOMHistory.pushState]

如果我将选择器更改为字符串,那么错误消失...但我需要jQuery对象,所以我可以在"popstate"事件上触发它点击:s

javascript jquery html5 history

8
推荐指数
2
解决办法
3584
查看次数

标签 统计

css ×1

css-selectors ×1

history ×1

html ×1

html5 ×1

javascript ×1

jquery ×1