所以我有这段代码<a href="#original" data-toggle="tab"><strong>text</strong></a>
当我点击某个按钮时,会创建一个href =&#34; #original,现在我的问题是如何创建一个条件来查看是否创建了这个特定的href?
$(document).ready(function() {
if ($("[attribute$='#original'").length) {
console.log('test');
}
});
这是我到目前为止所做的。
答案 0 :(得分:3)
$( document ).ready(function() {
if ( $("a[href='#original']").length ) {
console.log('test');
}
});
使用属性href来找到它
答案 1 :(得分:0)
$( document ).ready(function()
{
if ($("[href$='#original'").length )
{
console.log($('a').attr('href'));
}
});