2014-07-19 72 views
-2

我想要实现的是获得锚链接的名称,我已经做了,但由于一些奇怪的原因,它不会在if语句中工作。 我已经成功提醒锚名称,但不管它在if语句中不会出现什么内容。任何想法为什么?如果语句不工作在JQuery

感谢

echo "<br> 
    <div id='clicked_linked_$post_id_row' class='comment_field'> 

    <div id='showit_$post_id_row' style='display:none;'> 
<form action='' method='POST''> 
<textarea name='comment_post' class='comment_post'placeholder='What Is Your Thought?'></textarea> 
<input type='hidden' name='post_id_value' id='post_id_value' class='post_id_value' value='$post_id_row'><br> 
<input type='submit' value='Reply'> 
</form> 
</div> 
<small> <a href='#' class='comment_link' id='$post_id_row'> Comment$post_id_row </a> </small> 

</div><br> 
"; 

JQuery的

$(document).ready(function() { 


$('.comment_link').click(function() { 
var t = $(this).text(); 
alert(t); 
if($(this).text()=='Comment64') { 
alert(9); 
} 

}); 

$(document).on("click", ".comment_link", function(){ 



var id = this.id; 

    $('#showit_'+id).fadeIn(1000); 

    return false; 

}); 
}); 
+0

这个问题是不可能理解的。请尽力写出正确的英文短语。 –

+0

我基本上说,如果语句不工作在所有jquery –

+0

你可以发布你的标记的锚。 – Mritunjay

回答

0

在你的锚点你有空间arouund文本,即。 _Comment64_而不是Comment64,其中_是一个空格。 See fiddle

+0

是的感谢负载:D认为这是jQuery的东西不是实际的HTML我会投票但没有另一个代表,但我接受它 谢谢堆队友! –

1

正确它

if(this.text=='Comment64') 

if(t=='Comment64') 

if($(this).text()=='Comment64') 
+0

仍然doesen't工作:/我觉得奇怪它将不会在任何if语句中工作,但警告它很好,并感谢尝试帮助;) –

+1

尝试如果 –

+0

尝试更新的代码,所以你可以看看:/ 再次感谢;) –