jQuery 查找具有自定义属性 1 和 2 的元素

jQuery find element with custom attribute 1 and 2

我写了这段代码来加载动态内容:

$('.item').click(function(){
  var path = $(this).attr('path')
});

这将在加载内容时创建锚点 links:

var title = $(this).attr('title');
window.location.hash = title ;

这部分检查加载了哪些内容:

var title = $('.item').attr('title');
if (window.location.href.indexOf(title) > -1) {
  console.log("found it");
}

现在我想通过锚点加载内容 link 所以我需要获得一个标题适合路径的元素。 HTML 标记如下所示:

<div class="item" path="/mainfolder/subfolder/item/" title="I'am the title">

你有什么想法做这样的事情吗?我只需要知道如何使用以下元素搜索元素:attribute 1 which has attribute 2

谢谢大家的回答!

这样就select了^^

if($('[path="/mainfolder/subfolder/item/"]').length > 0){
  console.log("Found1!");
};
if($('[title="I\'am the title"]').length > 0){
  console.log("Found2!");
};

if($('[path="/mainfolder/subfolder/item/"][title="I\'am the title"]').length > 0){
  console.log("Found3!");
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input class="item" path="/mainfolder/subfolder/item/" title="I'am the title"/>