我试图从列表中排除某些元素。
页面http://www.persimmonhomes.com/rooley-park-10126上的我想要废弃的元素是(div class =“housetype js-filter-housetype”),还有那些我不想废弃的元素(div类) =“housetype js-filter-housetype”style =“display:none;”)
html看起来像:
isFinished;
finishedTodo(key: string, finished: boolean){
var snapshotFinished = this._af.database.object('hr/todos/'+ key,{ preserveSnapshot: true})
snapshotFinished.subscribe(snapshot => {
this.isFinished = snapshot.val().finished;
});
if (this.isFinished == false || this.isFinished == null){
this.todos.update(key,{finished: true});
console.log('is false');
}
else{
this.todos.update(key,{finished: false});
console.log('is true');
}
}
我正在尝试编写代码来排除div class =“housetype js-filter-housetype”style =“display:none;”。
我目前的代码是:
<div class="housetype js-filter-housetype">
<div class="housetype js-filter-housetype">
<div class="housetype js-filter-housetype">
<div class="housetype js-filter-housetype">
<div class="housetype js-filter-housetype">
<div class="housetype js-filter-housetype" style="display: none;">
<div class="housetype js-filter-housetype" style="display: none;">
到目前为止,这不起作用。它只是废弃所有元素,无论它是否有部分(style =“display:none;”)。我也试过[不(包含(@style,“display:none;”))] - 但到目前为止还没有运气。
我可以要求任何想法吗?答案 0 :(得分:2)
如果要使用style属性忽略all:
"//div[@class='housetype js-filter-housetype' and not(@style)]"
或者那个特定的风格,只需使用and
:
"//div[@class='housetype js-filter-housetype' and not(contains(@style,'display: none;'))]"